jquery esqyUI datagrid editor:{type:'combobox'} 数据源




<th 
field="level" 
width="80" 
editor="{
type:'combobox',
options:{required:true,
editable:false,
data:
[
{'id':'1,'text':'高速公路'},
{'id':'2','text':'一级公路'},
'id':'3','text':'二级公路'},
{'id':'4','text':'三级公路'}
],
valueField:'id',
textField:'text'}}">
路线等级</th>



{
	field : "unitId",
	title : "单位",
	width : 30,
	align : "right",
	sortable : true,
	formatter : unitFormatter,
	editor : {
		type : "combobox",
		options : {
			data : unitJSON, /* unitJSON是JSON格式的对象数组 */
			valueField : "value",/* value是unitJSON对象的属性名 */
			textField : "name"/* name是unitJSON对象的属性名 */
		}
	}
}, { /* datagrid其它字段配置.... */}



	function unitFormatter(value, rowData, rowIndex) {
		if (value == 0) {
			return "";
		}
		for (var i = 0; i < unitJSON.length; i++) {
			if (unitJSON[i].value == value) {
				return unitJSON[i].name;
			}
		}
		return value;
	}	


var unitJSON = [{
			"name" : "个",
			"value" : 2,
			"id" : 5,
			"group" : "UNIT_DDL"
		}, {
			"name" : "件",
			"value" : 3,
			"id" : 6,
			"group" : "UNIT_DDL"
		}, {
			"name" : "公斤",
			"value" : 23,
			"id" : 35,
			"group" : "UNIT_DDL"
		}];






你可能感兴趣的:(jquery esqyUI datagrid editor:{type:'combobox'} 数据源)