zoukankan      html  css  js  c++  java
  • Extjs4.2 GridPanel中显示单选按钮

    效果:如上图。

    代码:其中需要显示单选按钮的列

    {
                        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',
                        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);
            });
         }
      
    });
  • 相关阅读:
    (转)const变量通过指针修改问题
    sleep wait yeild join
    做事贵在坚持
    我的学习进度
    织梦dedecms后台添加图片style全部都变成st<x>yle的解决办法
    调用DEDE日期时间格式整理大全
    Arcgis andoid开发之应用百度地图接口实现精准定位与显示
    jquery自定义插件——window的实现
    lzugis—搭建属于自己的小型的版本控制SVN
    lzugis——Arcgis Server for JavaScript API之自定义InfoWindow
  • 原文地址:https://www.cnblogs.com/Y-X-DONG/p/6857775.html
Copyright © 2011-2022 走看看