jquery easyui组合框数据与子阵列

时间:2015-03-24 04:15:29

标签: javascript jquery jquery-easyui

以下是我的示例代码:

      <th data-options="field:'category',width:100,
                editor:{
                type:'combobox',
                options:{
                    valueField:'id',
                    textField:'categoryName',
                    method:'get',
                    url:'/categories/list',
                    required:true
                }}">Category</th>

My response data from url is:
{"rows":

[{"id":"4028b8814c4470d4014c4474ec4d0001","categoryName":"ASDFASDF","categoryDescription":"ASDFASDFASDF","status":"active","datetime":"2015-03-23T10:27:35.629+08:00"},
{"id":"4028b8814c41d8bd014c41dfd8dc0004","categoryName":"NO CATEGORY","categoryDescription":"NO CATEGORY","status":"active","datetime":"2015-03-23T10:27:35.629+08:00"},{"id":"4028b8814c4470d4014c447508e50002","categoryName":"ASDFASDF2","categoryDescription":"ASDFASDFASDF","status":"active","datetime":"2015-03-23T10:27:42.949+08:00"},

{"id":"4028b8814c4470d4014c447c2c4d0003","categoryName":"ASDFASDF","categoryDescription":"ASDFASDF","status":"active","datetime":"2015-03-23T10:35:30.765+08:00"},

{"id":"4028b8814c4470d4014c44a00d6e0004","categoryName":"TEST1","categoryDescription":"ADFASDFAFD","status":"active","datetime":"2015-03-23T11:14:42.154+08:00"}]

,"total":5,"item":""}

正如您所看到的,列表所需的数据位于&#39;行内。阵列。 有没有关于jquery easyui组合框的选项来获取数据&#39;行&#39;?

谢谢, ModLoaded

1 个答案:

答案 0 :(得分:0)

使用Ajax调用加载JS变量并使用该JS变量加载组合框。

var comboData=null;

$.ajax({url: '/categories/list',
        type: "GET",
        dataType: 'json',
        success: function (output, status, xhr) {   
               comboData=output.rows;
          }
});

在您的组合框中,使用如下,

<th data-options="field:'category',width:100,
                    editor:{
                    type:'combobox',
                    options:{
                        valueField:'id',
                        textField:'categoryName',
                        method:'get',
                        data:comboData,
                        required:true
                    }}">Category</th>