Reconfiguring grid columns in ExtJs4 - SelModel disappears?

北城余情 提交于 2019-12-24 02:18:14

问题


I am defining a grid which has a selModel.
Each time the store loads, the grids columns are dynamically reconfigured using the grids Reconfigure method.
However when I do this the grids selModel disappears.
How can I reconfigure the grids columns to also include the selModel.
Below is some example code:

//The Selection Model for the grid.
var sm = new Ext.selection.CheckboxModel();

//The Grid
var grid = new Ext.grid.Panel({
    store: store,
    selModel: sm,
    columns:[{
            header: 'Loading ...'
        }]
 });

//The store on load event where the columns are reconfigured
store.on('load', function(store){
    var columns = store.data.Data.items;
    grid.reconfigure(store, columns);
}, this);

In ExtJs3 I could specify the selModel as a column itself but this is not the case in ExtJs4. So how can I ensure the selModel is always visible even after reconfiguring the grids columns?


回答1:


It's a bug which is reported in Extjs version [4.0.2]. Now, it has resolved in Extjs version [4.0.7].




回答2:


From the 3.3.1 API docs (my emphasis):

Reconfigures the grid to use a different Store and Column Model and fires the 'reconfigure' event. The View will be bound to the new objects and refreshed. Be aware that upon reconfiguring a GridPanel, certain existing settings may become invalidated. For example the configured autoExpandColumn may no longer exist in the new ColumnModel. Also, an existing PagingToolbar will still be bound to the old Store, and will need rebinding. Any plugins might also need reconfiguring with the new data.

I believe you just need to re-set the SelectionModel after you reconfigure your grid.



来源:https://stackoverflow.com/questions/6277991/reconfiguring-grid-columns-in-extjs4-selmodel-disappears

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!