[Andrew]Ext.net Grid常用js

时间:2022-08-26 06:18:48

var gridFunction= function (gridId) {
                //获取当前Grid
                var gridView = Ext.getCmp(gridId);

      //获取当前选中行
                var selectedData = gridView.getSelectionModel().getSelection();

//选中数据总行数

var selectCount=selectedData.length;

//获取Grid Store数据
                var store = gridView.getStore();

//当前Grid的所有数据

var allData=store.data;

//当前Grid数据总行数

var sumCount=allData.length;

      var cloumnData = [];

//判断Grid是否有选中数据
                if (gridView.getSelectionModel().hasSelection()) {
                    for (var i = 0; i < selectedData.length ; i++) {

         //当前选中行数据

         var currentData=selectedData[i].data;

//移除当前行数据
                        store.remove(selectedData[i]);

//获取当前行某列数据

         var name=selectedData[i].data.Name;

       //将当前行数据添加到数组当中

        cloumnData.push(currentData);
                    }

        //序列化Grid的数据

       return Ext.JSON.encode(cloumnData);
                }

      return "";
    };