简体   繁体   English

SlickGrid:重新排序后排序不起作用

[英]SlickGrid: sorting after reordering doesn't work

In SlickGrid you can enable row reordering (drag and drop). 在SlickGrid中,您可以启用行重新排序(拖放)。 See http://mleibman.github.io/SlickGrid/examples/example9-row-reordering.html 参见http://mleibman.github.io/SlickGrid/examples/example9-row-reordering.html

My problem is that once I reorder a row (eg put row 3 above row 1) I can't sort the entries anymore. 我的问题是,一旦我对一行进行重新排序(例如,将第3行放在第1行上方),就无法再对条目进行排序。 If a column is named "date" and I click on that column, nothing happens. 如果某列名为“日期”,而我单击该列,则不会发生任何事情。 On the other hand, if I do not reorder the rows manually and then sort by column, it works. 在另一方面,如果我被列手动,然后重新排序行排序,它的工作原理。

I don't mind that the "sort by column" will destroy my manual order. 我不介意“按列排序”会破坏我的人工订单。 I just want to keep the option to sort it by column after the reorder. 我只想保留重新排序后按列排序的选项。

Any tips are appreciated. 任何提示表示赞赏。

(I am using SlickGrid because there's a nice fork which features sticky rows/columns. I haven't found this feature elsewhere, so it's my only option) (我使用SlickGrid是因为有一个很好的fork,它具有粘性的行/列。在其他地方没有找到此功能,因此这是我唯一的选择)

When the grid is manually reordered the function subscribed to moveRowsPlugin.onMoveRows is executed. 手动对网格重新排序后,将执行预订moveRowsPlugin.onMoveRows的函数。 This function is calling grid.setData(data) to update the reordered rows onto the grid. 此函数正在调用grid.setData(data)以将重新排序的行更新到网格上。 Calling grid.setData(data) overrides the DataView and directly sets the data on the grid. 调用grid.setData(data)会覆盖DataView并直接在网格上设置数据。 Updates made to the DataView (eg sorting) are therefore no longer reflected on the grid. 因此,对DataView的更新(例如排序)不再反映在网格上。

To resolve this change grid.setData(data) to dataView.setItems(data) in the function subscribed to moveRowsPlugin.onMoveRows (line 364 of the inline JavaScript). 若要解决此更改, grid.setData(data)在已预订moveRowsPlugin.onMoveRows的函数(嵌入式JavaScript的第364行dataView.setItems(data)中将grid.setData(data)更改为dataView.setItems(data) )。 I'd also recommend clearing the sort fields so the sort indicator is removed. 我还建议您清除排序字段,以便删除排序指示器。

//Set updated data in DataView
dataView.setItems(data);

//Clear sort columns
grid.setSortColumns([]);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM