【问题标题】:Unable to bind the jqGrid Column无法绑定 jqGrid 列
【发布时间】:2020-04-10 22:32:22
【问题描述】:

我正在尝试使用 jqGrid。网格正在出现,但后端值没有绑定到网格中。行显示为空白。

只有两行来自后端。行生成正确,分页正确,但列中的值未绑定。

当我要检查时,只有 &nbps 存在。

提前致谢。

<script>
        $(function () {
            debugger;
            $("#grid").jqGrid
                ({
                    url: "/client/GetAllClient",
                    datatype: 'json',
                    mtype: 'Get',
                    //table header name
                    colNames: ['Id', 'Client ID'],
                    //colModel takes the data from controller and binds to grid
                    colModel: [
                        {
                            key: true,
                            hidden: true,
                            name: 'Id',
                            index: 'Id',
                            editable: true
                        }, {
                            key: false,
                            name: 'ClientID',
                            index: 'ClientID',
                            editable: true
                        }],

                    pager: jQuery('#pager'),
                    rowNum: 10,
                    rowList: [10, 20, 30, 40],
                    height: '100%',
                    viewrecords: true,
                    caption: 'Jq grid sample Application',
                    emptyrecords: 'No records to display',
                    jsonReader:
                    {
                        root: "rows",
                        page: "page",
                        total: "total",
                        records: "records",
                        repeatitems: false,
                        Id: "0"
                    },
                    autowidth: true,
                    multiselect: false
                    //pager-you have to choose here what icons should appear at the bottom
                    //like edit,create,delete icons
                }).navGrid('#pager',
                    {
                        edit: true,
                        add: true,
                        del: true,
                        search: false,
                        refresh: true
                    });
        });
    </script>
  <table id="grid"></table>
        <div id="pager"></div>

这是我的代码---

var Results = _objModel.Select(x => new
            {
                x.ClientID
            });

            var jsonData = new
            {
                total = totalPages,
                page,
                records = totalRecords,
                rows = Results
            };
            return Json(jsonData);

JqGrid 现在的样子:

【问题讨论】:

    标签: c# jquery asp.net-mvc jqgrid mvcjqgrid


    【解决方案1】:

    问题已解决。这是区分大小写的愚蠢错误。在绑定时,我使用“ClientID”代替“clientID”。

    现在可以正常使用了。

    【讨论】:

      猜你喜欢
      • 2011-01-17
      • 1970-01-01
      • 2013-09-12
      • 2016-06-09
      • 1970-01-01
      • 1970-01-01
      • 2013-05-04
      • 1970-01-01
      • 2017-12-21
      相关资源
      最近更新 更多