【发布时间】:2015-04-02 21:57:33
【问题描述】:
我有一个带有定义模型的网格,但它应该只显示用户选择查看的列,并按照他选择的顺序显示。
业务需求不是使用内置的列标题菜单对列进行排序/隐藏,也不是使用拖放功能对列进行排序,而是使用一个对话框,用户可以从一个对话框中选择“选定的列” “可用列”列表,他还可以在其中设置列的显示顺序。
我需要构建一个简单的方法,在给定列 dataIndexes 的数组中,它应该仅显示与数组匹配的列,并按给定顺序。
为方便起见,这里有一个fiddle,其中有一个名为setColumnsPreferences 的方法,它给定一个网格和一个dataIndexes 数组,它应该:
- 仅显示与给定数据索引匹配的列。
-
按给定顺序显示它们(与给定数组中的顺序相同)
/** * Given a grid object and an array containing the data indexes * of the columns that we want to display, this function should * make the grid to display only the given columns, and in the * order as they appear on the columns array * @param {Ext.grid.Panel} grid The grid we want to modify * @param {Array} columns A string array */ setColumnsPreferences : function(grid, columns) { alert("not yet implemented, columns: " + columns); },
【问题讨论】: