Extjs4之Grid监听排序事件

  1. var grid = Ext.create('Ext.grid.Panel', {  
  2.     border: true,  
  3.     stripeRows: true,  
  4.     columns: [  
  5.         { xtype: 'rownumberer' },  
  6.         { text: '学期', dataIndex: 'schoolTerm', align: 'center', flex: 1 }  
  7.     ],  
  8.     selModel: sm,  
  9.     store: studentStore,  
  10.     columnLines: false,  
  11.     loadMask: { msg: '数据加载中,请稍候...' },  
  12.     listeners: {  
  13.         //添加排序改变事件  
  14. p;           sortchange: function (ct, column, direction, eOpts) {  
  15.             var title = column.textEl.getHTML();//获取列表头的文本  
  16.             if (title == "学期") {  
  17.                 var sortType = Ext.util.Format.uppercase(direction);//获取排序方式“DESC”或“ASC”  
  18.                 if ("DESC" == sortType) {  
  19.                     studentStore.sort('schoolTermId''DESC');  
  20.                 } else {  
  21.                     studentStore.sort('schoolTermId''ASC');  
  22.                 }  
  23.                 studentStore.load({//加载数据  
  24.                     scope: this,  
  25.                     callback: function (records, operation, success) {  
  26.                         var responseData = studentStore.getProxy().getReader().rawData;  
  27.                         if (typeof (responseData) == "undefined") {  
  28.                             return;  
  29.                         }  
  30.                         var responseMsg = responseData.msg;  
  31.                         var responseFlag = responseData.success;  
  32.                         if (responseFlag != null && responseFlag == false) {  
  33.                             Ext.Msg.alert('温馨提示''您好,查询信息失败!' + responseMsg);  
  34.                         }  
  35.                     }  
  36.                 });  
  37.             }  
  38.         }  
  39.     }  

  1. });  
  2. 来源:http://blog.csdn.net/hsg0123_126/article/details/38320969

你可能感兴趣的:(EXT,JS4)