关于easyUI

时间:2024-01-18 12:41:56
<input class="easyui-combobox" id="s_dataDicName" data-options="panelHeight:'auto',editable:false,valueField:'dataDicName',textField:'dataDicName',url:'${pageContext.request.contextPath}/dataDic/findDataDicName.do'"/>

其中:

1.

valueField属性定义下拉框的value域的字段,即需要保存到库的值,如数据库中code或id字段

textField属性定义下拉框的text域字段,即下拉框选中要显示的值,一般做来显示用的

2.

url属性是请求地址,后台获取的数据一定要是jsonArray(json数组)才能解析

①:jsonArray:即json数组,格式是:[{key:value,key:value},{key:value,key:value},{key:value,key:value}]

例如:

[{"dataDicName":"客户等级","dataDicValue":"","id":0},{"dataDicName":"服务类型","dataDicValue":"","id":0}]

②:jsonObject:即json对象,格式是:{key:value}

例如:

{"rows":[{"dataDicName":"客户等级","dataDicValue":"普通客户","id":1}, {"dataDicName":"客户等级","dataDicValue":"重点开发客户","id":2},{"dataDicName":"客户 等级","dataDicValue":"大客户","id":3},{"dataDicName":"客户等级","dataDicValue":"合 作伙伴","id":4},{"dataDicName":"客户等级","dataDicValue":"战略合作伙伴","id":5}, {"dataDicName":"服务类型","dataDicValue":"咨询","id":6},{"dataDicName":"服务类 型","dataDicValue":"建议","id":7},{"dataDicName":"服务类型","dataDicValue":"投 诉","id":8}],"total":8}

上面例子是easyUI-datagrid分页需要的数据,首先这个数据必须为jsonObject,第二它需要两个数据:

1.key:rows   value:一个jsonArray数组(一个数组有很多jsonObject)

2.key: total   value:所查询出来数据的记录数,利用这两个数据datagrid会自动计算每页的数据。