Extjs4.2 GridPanel中顯示選項按鈕

來源:互聯網
上載者:User

標籤:hid   center   enter   eem   javascrip   html   define   hidden   tco   

效果:如。

代碼:其中需要顯示選項按鈕的列

{                    dataIndex: ‘FeeModel‘,                    text: ‘收費模式‘,                    flex: 1,                    align: ‘left‘,                    radioValues: [{ "inputValue": "1", "boxLabel": "高級收費模式" }, { "inputValue": "2", "boxLabel": "簡單收費模式" }, { "inputValue": "3", "boxLabel": "不收費模式" }],                    renderer:function(value, metaData, record, rowIndex, colIndex, store, view) {                          var column = view.getGridColumns()[colIndex],                              html = ‘‘;                          Ext.each(column.radioValues, function(rec) {                              var inputValue = rec.inputValue;                              var boxLabel = rec.boxLabel;                              var checked = inputValue == value;                              var name =  view.id+"_Grdi_Column_Radio_"+record.data.Id+"_"+rowIndex;                              html += "<input name=‘" + name + "‘ type=‘radio‘ " + (checked ? "checked" : "") + "  colIndex=‘" + colIndex + "‘  rowIndex=‘" + rowIndex + "‘ value=‘" + inputValue + "‘/>" + boxLabel;                        });                          return html;                      },                    tdCls: ‘tdValign‘                }

  給表格加入事件

  me.on(‘afterrender‘, function (grid, eOpts) {                       this.el.on(‘click‘, function (event) {                var radio = event.getTarget(‘input[type="radio"]‘);                if (radio) {                    var rowIndex = radio.getAttribute("rowIndex");                    var colIndex = radio.getAttribute("colIndex");                    this.getStore().getAt(rowIndex).set(‘FeeModel‘,radio.value);                }            }, this);        });

  表格全部代碼:

Ext.define(‘Yxd.view.FeeModelSet.ProjectGrid‘, {    extend: ‘Yxd.ux.BaseGridPanel‘,    xtype: ‘FeeModelSet_ProjectGrid‘,    border: 0,   initComponent: function () {        var me = this;        var store = Ext.create("Yxd.store.Project", {            autoLoad: true        });             Ext.applyIf(me, {            store: store,            columns: [               {                   flex: 1,                   dataIndex: ‘Id‘,                   text: ‘Id‘,                   hidden: true,                   align: ‘center‘               }, {                   text: ‘序號‘,                   xtype: ‘rownumberer‘,                   width: 50,                   tdCls: ‘tdValign‘,                   align: ‘center‘               },                {                    dataIndex: ‘Name‘,                    text: ‘項目名稱‘,                    flex: 1,                    align: ‘left‘,                    tdCls: ‘tdValign‘                }, {                    dataIndex: ‘FeeModel‘,                    text: ‘收費模式‘,                    flex: 1,                    align: ‘left‘,                    radioValues: [{ "inputValue": "1", "boxLabel": "高級收費模式" }, { "inputValue": "2", "boxLabel": "簡單收費模式" }, { "inputValue": "3", "boxLabel": "不收費模式" }],                    renderer:function(value, metaData, record, rowIndex, colIndex, store, view) {                          var column = view.getGridColumns()[colIndex],                              html = ‘‘;                          Ext.each(column.radioValues, function(rec) {                              var inputValue = rec.inputValue;                              var boxLabel = rec.boxLabel;                              var checked = inputValue == value;                              var name =  view.id+"_Grdi_Column_Radio_"+record.data.Id+"_"+rowIndex;                              html += "<input name=‘" + name + "‘ type=‘radio‘ " + (checked ? "checked" : "") + "  colIndex=‘" + colIndex + "‘  rowIndex=‘" + rowIndex + "‘ value=‘" + inputValue + "‘/>" + boxLabel;                        });                          return html;                      },                    tdCls: ‘tdValign‘                }]        });        me.callParent(arguments);        me.on(‘afterrender‘, function (grid, eOpts) {                       this.el.on(‘click‘, function (event) {                var radio = event.getTarget(‘input[type="radio"]‘);                if (radio) {                    var rowIndex = radio.getAttribute("rowIndex");                    var colIndex = radio.getAttribute("colIndex");                    this.getStore().getAt(rowIndex).set(‘FeeModel‘,radio.value);                }            }, this);        });     }  });

 

Extjs4.2 GridPanel中顯示選項按鈕

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.