ExtJS 6.2视图跳转后如何编程实现表格按ID列降序排序?
解决视图跳转后列表无法按ID降序排序的问题
有两种可行的解决思路,直接对应你的场景调整即可:
方法一:在跳转函数中主动触发排序
修改redirectToJobRequestPanel函数,在添加新面板后,找到对应的Grid和Store,手动执行排序逻辑:
redirectToJobRequestPanel: function() { console.log('redirectToJobRequestPanel called'); let mainContentPanel = Ext.getCmp('main-content-panel'); mainContentPanel.removeAll(); // 添加面板并获取实例 let requestedJobsPanel = mainContentPanel.add({ xtype: 'requestedjobsmain' }); // 查找面板内的Grid组件(根据你的实际结构调整down的参数,比如grid的id或xtype) let jobGrid = requestedJobsPanel.down('grid'); if (jobGrid) { // 获取Store并按ID降序排序 let store = jobGrid.getStore(); store.sort('id', 'DESC'); } this.setActiveMainNavTreeSelection(); },
方法二:在面板的Store中配置默认排序
如果希望requestedjobsmain面板每次加载都自动按ID降序,直接在该面板的Store定义中添加默认排序规则:
Ext.define('YourApp.view.RequestedJobsMain', { extend: 'Ext.panel.Panel', xtype: 'requestedjobsmain', items: [{ xtype: 'grid', store: { // 你的其他Store配置(model、proxy等) sorters: [{ property: 'id', direction: 'DESC' }] }, // Grid的列配置... }] });
这样每次加载该面板,Store会自动按ID降序排列数据,无需在跳转函数中额外处理。
内容的提问来源于stack exchange,提问作者user2107624
相关产品推荐
相关产品推荐

