首页 新闻 会员 周边 捐助

jquery easyui datagrid绑定显示出现了奇怪问题

0
悬赏园豆:30 [已解决问题] 解决于 2014-01-21 09:34

我的程序里有个奇怪的问题,当action返回的数据为一条时,datagrid可以正常显示,但是当action返回多于一条数据时,datagrid就无法正常显示了。很是奇怪,求指点。$('#product').datagrid({
        title: '产品信息',
        url: '/BaseData/GetProductsById',
        iconCls: 'icon-view',
        nowrap: true,
        autoRowHeight: false,
        striped: true,
        collapsible: false,
        rownumbers: true,
        sortName: 'ProductCode',
        sortOrder: 'asc',
        remoteSort: false,
        singleSelect:true,
        idField: 'ProductId',
        queryParams: queryPar,
        columns: [[
            { title: '串型编号主键', field: 'SerialId', width: 10, hidden: true },
            {
                title: '产品代码',
                field: 'ProductId',
                width: 100,
                sortable: true,
                formatter: function(value, row) {
                    return row.ProductCode;
                },
                editor: {
                    type: 'combogrid',
                    options: {
                        panelWidth: 450,
                        idField: 'ProductId',
                        textField: 'ProductCode',
                        sortName: 'ProductCode',
                        sortOrder: 'asc',
                        fitColumns: true,
                        remoteSort: false,
                        required: true,
                        url: '/BaseData/GetAllProducts',
                        columns: [[
                            { field: 'ProductId', title: '产品主键', width: 80, hidden: true },
                            { field: 'ProductCode', title: '产品代码', width: 80 },
                            { field: 'ProductModel', title: '产品型号', width: 100 },
                            { field: 'ProductName', title: '产品名称', width: 100 }
                        ]],
                        onSelect: function(rowIndex, rowData) {
                            if ($('#product').datagrid('validateRow', editIndex)) {
                                var modelEd = $('#product').datagrid('getEditor', { index: editIndex, field: 'ProductModel' });
                                $(modelEd.target).val(rowData.ProductModel);

                                var nameEd = $('#product').datagrid('getEditor', {
                                    index: editIndex,
                                    field: 'ProductName'
                                });
                                $(nameEd.target).val(rowData.ProductName);
                            }
                        }
                    }
                }
            },
            { title: '产品型号', field: 'ProductModel', width: 100, editor: 'text'},
            { title: '产品名称', field: 'ProductName', width: 100, editor: 'text'},
            { title: '数量', field: 'Quantity', width: 80, editor: 'numberbox' }
        ]],
        toolbar: [{
                id: 'btnNewRow',
                text: '添加',
                iconCls: 'icon-add',
                handler: function() {
                    Append();
                }
            }, '-', {
                id: 'btnDelete',
                text: '移除',
                iconCls: 'icon-remove',
                handler: function() {
                    Remove();
                }
            }, '-', {
                id: 'btnView',
                text: '结束编辑',
                iconCls: 'icon-save',
                handler: function() {
                    Accept();
                }
            }],
        onClickRow: onClickRow
    });
返回的  json为一条和两条的数据如下

{"total":2,"rows":[{"Id":"6fb79911-0031-4f6e-bc9a-0e4f3c6645cb","SerialId":"bb9fefac-4ea2-4e37-9241-0142624f1a7a","ProductId":"2d77ad36-5574-4b5f-9457-00294a9f7f17","ProductCode":"BGXJ","ProductModel":"JBB-1","ProductName":"并沟线夹","Quantity":1},{"Id":"f6b2a6a5-7bd7-4e89-9ceb-2ff62c74fee0","SerialId":"bb9fefac-4ea2-4e37-9241-0142624f1a7a","ProductId":"ec159fbd-b69a-4918-81c6-51edd0e9082b","ProductCode":"DXBCW","ProductModel":"FYH-300/40","ProductName":"导线包缠物","Quantity":1}]}


{"total":1,"rows":[{"Id":"a20aae22-a3c5-4fb4-9bdd-a8cb72630a2c","SerialId":"e0fa8758-6917-4a95-ab80-92b0fd7ef00a","ProductId":"c0f84858-03ec-438d-a6d5-7a36d5a35f2a","ProductCode":"DXBCW","ProductModel":"1*10","ProductName":"导线包缠物","Quantity":1}]}

prog_sky的主页 prog_sky | 初学一级 | 园豆:161
提问于:2014-01-20 17:00
< >
分享
最佳答案
0

"rows":[{"Id":"7" 

这里的Id 换成大写ID 试试 

收获园豆:30
Zery | 大侠五级 |园豆:6151 | 2014-01-21 09:26

不是大小写的问题,刚才通过实验已经验证了问题的所在。  title: '产品代码', field: 'ProductId'这里的field不能为ProductId,应该改为ProductCode

prog_sky | 园豆:161 (初学一级) | 2014-01-21 09:33
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册