ExtJS-Grid框增加複選框checkbox

來源:互聯網
上載者:User

標籤:des   style   blog   http   color   os   

 

var gridColumnModel = new Ext.grid.ColumnModel([                    new Ext.grid.RowNumberer(),                    new Ext.grid.CheckboxSelectionModel({ singleSelect: false }),//複選框                    {                        header : ‘資訊ID‘,                        dataIndex : ‘INFO_ID‘,                        sortable : true,                        align : ‘center‘,                        width : 80                    }, {                        header : ‘商品ID‘,                        dataIndex : ‘PRICE_PLAN_CD‘,                        sortable : true,                        align : ‘center‘,                        width : 100                    }, {                        header : ‘商品類型‘,                        dataIndex : ‘OFFERING_TYPE‘,                        sortable : true,                        align : ‘center‘,                        width : 70                    }, {                        header : ‘管理層級‘,                        dataIndex : ‘MANAGE_LEVEL‘,                        sortable : true,                        align : ‘center‘,                        width : 70                    }, {                        header : ‘管理編號‘,                        dataIndex : ‘MANAGE_CODE‘,                        sortable : true,                        align : ‘center‘,                        width : 110                    }, {                        header : ‘目錄ID‘,                        dataIndex : ‘CATEGORY_ID‘,                        sortable : true,                        align : ‘center‘,                        width : 100                    }, {                        header : ‘商品名稱‘,                        dataIndex : ‘NAME‘,                        sortable : true,                        align : ‘center‘,                        width : 150                    }, {                        header : ‘生效時間‘,                        dataIndex : ‘START_DT‘,                        sortable : true,                        align : ‘center‘,                        width : 120                    }, {                        header : ‘失效時間‘,                        dataIndex : ‘END_DT‘,                        sortable : true,                        align : ‘center‘,                        width : 120                    }, {                        header : ‘員工ID‘,                        dataIndex : ‘STAFF_CODE‘,                        sortable : true,                        align : ‘center‘,                        width : 110                    }, {                        header : ‘建立時間‘,                        dataIndex : ‘CREATE_DT‘,                        sortable : true,                        align : ‘center‘,                        width : 120                    }, {                        header : ‘版本時間 ‘,                        dataIndex : ‘VERSION‘,                        sortable : true,                        align : ‘center‘,                        width : 120                    }, {                        header : ‘地區ID‘,                        dataIndex : ‘AREA_ID‘,                        sortable : true,                        align : ‘center‘,                        width : 100                    }, {                        header : ‘描述‘,                        dataIndex : ‘DESCRIPTION‘,                        sortable : true,                        align : ‘center‘,                        width : 145                    }, {                        header : ‘商品狀態‘,                        dataIndex : ‘OFFERING_STATUS_CD‘,                        sortable : true,                        align : ‘center‘,                        width : 100                    }]);
 1 var grid = new CDEXT.grid.PageGrid({ 2                         cm : gridColumnModel, 3                         sm: new Ext.grid.CheckboxSelectionModel ({ singleSelect: false }),//複選框 4                         store : store, 5                         title : ‘<div align="center">商品資訊</div>‘, 6                         stripeRows : true, 7                         region : ‘north‘, 8                         autoScroll : true, 9                         height : 300,10                         tbar : [‘需求單ID:‘ ,reqIdField, ‘-‘, ‘需求單名:‘,requestField, ‘-‘, ‘商品名:‘, textField, ‘-‘, ‘開始時間(建立):‘,11                                 startDate, ‘-‘, ‘結束時間(建立):‘, endDate, ‘-‘,12                                 deaSearch,insertSearch],13                         bbar : true,14                         stripeRows : true,15                         loadMask : {16                             msg : ‘正在載入資料,請稍侯......‘17                         },18                         listeners : {19                             ‘rowclick‘ : function() {20                                 var record = grid.getSelectionModel()21                                         .getSelected();22                                 if (record) {23                                     var instanceId = record24                                             .get(‘PRICING_INSTANCE_ID‘);25                                     pmstore.setBaseParam("search.prInsId",26                                             instanceId);27                                     pmgrid.reload();28                                 }29                             }30                         }31                     });

 

上述樣本,效果如下

 

 

關鍵點:

在ColumnModel中增加:

new Ext.grid.CheckboxSelectionModel({ singleSelect: false })//複選框

在Grid中增加:

sm: new Ext.grid.CheckboxSelectionModel ({ singleSelect: false })//複選框

 

取值時:

          var records=grid.getSelectionModel().getSelections();
          var mycars=new Array();
         
         for(var i=0;i<records.length;i++){
             mycars[i]=records[i].data.INFO_ID;
         };

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.