重排序列表 [英] Reordering an ordered list
问题描述
我有一个以下SQL表与数据
I have a following SQL table with data
ProductList
id order productname
79 1 name1
42 2 name2
67 3 somename
88 4 othername
99 5 XYZ
66 6 ABC
显示顺序非常不稳定,频繁更改,用户将添加或删除项目并重新排列项目。
Display order is very volatile, it will change frequently, users will add or remove items and reorder the items.
如何处理这种情况,而不更新多个记录。示例:如果用户在1到2之间输入新产品,我不想更新2以下所有记录的顺序,如果有人将订单3更改为4,我不想更新3以下的每个记录。 p>
How should i handle this situation without updating multiple records. Example: if user enters a new product between 1 and 2 order, i do not want to update the order of all the records beneath 2 and if someone switch order 3 to 4 i don't want to update every record under 3.
推荐答案
使用旧的BASIC编码器使用orrible old trick made famous(?) - 将您的订单设置为100,200,300, 400等等,然后你可以选择一个订单中间,当你需要。这可能会变得混乱 - 如果您期待很多重新排序,那么我建议您有一个计划的任务,以便重新排序订单值,然后再整个表格。
Use the 'orrible old trick made famous(?) by old BASIC coders - set your orders to be 100, 200, 300, 400 etc. and then you can pick an order 'inbetween' when you need to. This could get messy - and if you're anticipating a lot of reordering then I'd recommend that you have a scheduled task to 'reorder' the order values every now and then for the entire table.
这篇关于重排序列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!