Jquery Bootgrid首先加载数据,然后清空

问题描述 投票:0回答:1

我无法弄清楚我在哪里错了。我有一个jquery bootgrid,并且完全按照示例中的指示进行操作,但是发生的是页面最初加载的是未格式化的数据,然后将jquery bootgrid格式化应用了一会儿,接着是空白,然后消息“正在加载...”代替数据。因此,它最初可以正常运行,但是随后失败了,我不知道为什么。通过调试器,我得到关于url的异常不能为空,但是我没有使用API​​来获取此数据,而是将其读入并将其直接加载到表中(如代码所示)。如果我包含一个无用的url设置,那么我会得到“无结果”,这是有道理的,因为没有数据来自该url,但是网格运行正常。没有url参数,如何使它工作?

HTML:

 <table id="ResultsGrid" name="ResultsGrid" runat="server" data-side-pagination="server" data-pagination="true" class="table table-extracondensed table-bordered table-striped">
            <thead>
                <tr class="info">
                    <th data-column-id="CaseID" data-identifier="true" data-formatter="link">Case ID</th>
                    <th data-column-id="Status">Status</th>

                </tr>
            </thead>
            <tbody>
                @if (Model.Results != null && Model.Results.Count() > 0)
                {

                    foreach (var result in Model.Results)
                    {
                        <tr>
                            <td><a style="cursor:pointer" href="/[email protected]">@result.CaseID</a></td>
                            <td>@result.Status</td>

                        </tr>
                    }
                }
            </tbody>
        </table>

Javascript:


       $(document).ready(function () {
            $('.datepicker').datepicker();

            $("#ResultsGrid").bootgrid({
                ajax: true,
                post: function () {
                    return {
                        id: "b0df282a-0d67-40e5-8558-c9e93b7befed"
                    };
                },
                selection: true,
                multiSelect: true,
                formatters: {
                    "link": function (column, row) {
                        return "<a href=\"#\">" + column.id + ": " + row.id + "</a>";
                    }
                }

            }).on("selected.rs.jquery.bootgrid", function (e, rows) {
                var rowIds = [];
                for (var i = 0; i < rows.length; i++) {
                    rowIds.push(rows[i].id);
                }
                alert("Select: " + rowIds.join(","));
            }).on("deselected.rs.jquery.bootgrid", function (e, rows) {
                var rowIds = [];
                for (var i = 0; i < rows.length; i++) {
                    rowIds.push(rows[i].id);

                }
                alert("Deselect: " + rowIds.join(","));
            });


        });
    </script>
jquery datagrid
1个回答
0
投票

我知道了。显然,如果ajax = true,则需要url参数。一旦删除并重新调整了某些功能,我就可以使用它。

© www.soinside.com 2019 - 2024. All rights reserved.