【问题标题】:jsGrid not displaying cell data after rows are retrieved检索行后jsGrid不显示单元格数据
【发布时间】:2020-07-09 01:06:03
【问题描述】:

我有一个返回项目的控制器:

    [HttpGet]
    public ActionResult GetAll(int pageIndex, int pageSize)
    {
        var data = repository.GetAll(pageIndex, pageSize);

        return Ok(new
        {
            data,
            itemsCount = data.Count()
        });
    }

jsGrid 设置是:

function setup() {
    $("#grid").jsGrid({
        width: "100%",
        height: "auto",

        sorting: true,
        paging: true,
        autoload: true,
        pageLoading: true,

        pageSize: 15,
        pageButtonCount: 5,

        controller: {
            loadData: function (filter) {
                return $.ajax({
                    type: "GET",
                    url: "/api/clients",
                    data: filter,
                    dataType: "JSON"
                });
            },
        },

        fields: [
            { name: "Id", type: "number", width: 50, visible: false },
            { name: "Date", type: "text", width: 100 },
            { name: "Client", type: "text", width: 200 },
            { name: "User", type: "text", width: 200 }
        ]
    });
};

$(document).ready(function () {
    setup();
});

表格中填充了行,但单元格为空。我错过了一些映射吗?

【问题讨论】:

    标签: javascript c# asp.net jsgrid


    【解决方案1】:

    使用 Chrome 网络选项卡检查您的 ajax 结果。你可以发现在 JSON 对象中,属性名是小写的。所以jsGrid不能很好地映射。

    Asp.Net Core 返回带有小写名称的 JSON 对象。

    【讨论】:

      【解决方案2】:

      正如高丽圭所说: 首先,查看检查元素的控制台选项卡并确保您在方法调用中没有错误。 然后转到检查元素的网络选项卡并找到 ypu request&response 并检查该方法是否给出响应并检查您对模型的响应(根据字段的名称和类型),如果所有这些部分都正确,请检查您的 js 函数并尝试进入多个迷你功能,直到找出代码中的错误以进行修复。 我希望这个答案对你有所帮助。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-04-30
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多