Extjs GridPanel 添加使用单选按钮radio

columns[
{
	                text : "表决意见",
	                width : 160,
	                flex:1,
	                dataIndex : "custom1",
	                radioValues:[{"inputValue":"1","boxLabel":"同意"},{"inputValue":"0","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.internalId+"_"+rowIndex;
					         html +=  "<input name='"+name+"' type='radio' "+ (checked?"checked":"")+"  dataindex='"+column.dataIndex+"' value='"+inputValue+"' />"+boxLabel;
				        });
				        return html;
				    }
	            }
]


grid添加监听

afterRender:function() {
		        this.superclass.afterRender.apply(this, arguments);
		        this.el.on('click',function(event) {
			    	var radio = event.getTarget('input[type="radio"]');
			        if (radio) {
			        	var dataindex = radio.getAttribute("dataindex");
			            event.record.set(dataindex,radio.value);
			        }
			    }, this);
		    }


相关推荐
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页