开发者

How to make the records movable? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

In rails 3.1

I want to make the db records movables, with a Move up and a Move down link in ecah one. For example, if I have 4 records:

Title 1 [up] [开发者_JS百科down]

Title 2 [up] [down]

Title 3 [up] [down]

Title 4 [up] [down]

I could click in the Title 3's up link and the new table would be:

Title 1 [up] [down]

Title 3 [up] [down]

Title 2 [up] [down]

Title 4 [up] [down]


Add an Order field to the Table. Then when the person clicks the move up or move down, add or subtract 1 from that field. Make sure this field doesn't go below 0 or above the number of entries - 1 in your table. When you wan't to display these fields in order, just order them by this field.

Moving rows 'up and down' in a database (SQL query help)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜