【问题标题】:JSGrid not showing filter input fieldsJSGrid 不显示过滤器输入字段
【发布时间】:2019-05-17 20:08:56
【问题描述】:

我希望输入过滤器字段按预期创建并显示在标题行单元格下。

在我的 MVC 解决方案中,我的 JSGrid 通过 AJAX/JSON/GET 填充。我能够对 loadData javascript 等进行排序并单步执行。当我添加“filtering:true”时,会在标题行和表体行之间生成一个带有单元格的行,但输入字段不存在。我尝试过包含不同的 CSS、JQuery 和 JS 库,并尝试模仿许多演示和示例..

function RenderImportHistory() {
    $("#jsGrid_ImportHistory").jsGrid({
        width: "100%",
        height: "572px",
        pageSize: 10,
        pageButtonCount: 5,

        filtering: true,
        editing: true,
        sorting: true,
        paging: true,
        autoload: true,

        loadIndication: true,
        loadIndicationDelay: 500,
        loadMessage: "Getting Import History ...",

        controller: {
            loadData: function (filter) {
                var d = $.Deferred();
                $.ajax({
                    url: "@Url.Action("GetImportHistory", "SCAL", new { Area = "Admin" })",
                    dataType: "json",
                    type: "GET"
                }).done(function(result) {
                    /*result = $.grep(result, function(item) {
                        return item.patientId === filter.patientId
                           && item.patientName === filter.patientName
                           && item.genderId === filter.genderId
                           && item.mobile === filter.mobile;

                    }); */
                    d.resolve(result);
                });
                return d.promise();
            }
        },
        fields: [
            { name: "ID", type: "Number", css: "jsGrid_Body", headercss: "jsGrid_Head", width: 11, sorter:"number" },
            { name: "ImportSched_ID", type: "Number", title: "Schedule", css: "jsGrid_Body", headercss: "jsGrid_Head", width: 27, sorter:"number" },
            { name: "Created", type: "Text", title: "Started", css: "jsGrid_Body", headercss: "jsGrid_Head", itemTemplate: function (value) { return FormatDateTime(value); } },
            { name: "Completed", type: "Text", title: "Ended", css: "jsGrid_Body", headercss: "jsGrid_Head", itemTemplate: function (value) { return FormatDateTime(value); } },
            { name: "NumOfClaims", type: "Number", title: "Claims", css: "jsGrid_Body", headercss: "jsGrid_Head", width: 21, sorter: "number", itemTemplate: function (value) { return FormatCounts(value); } },
            { name: "NumOfRecords", type: "Number", title: "Rows", css: "jsGrid_Body", headercss: "jsGrid_Head", width: 21, sorter: "number", itemTemplate: function (value) { return FormatCounts(value); } },
            { name: "TimeToRead_Seconds", type: "Number", title: "Read", css: "jsGrid_Body", headercss: "jsGrid_Head", width: 21, sorter: "number", itemTemplate: function (value) { return FormatDuration(value); } },
            { name: "TimeToWrite_Seconds", type: "Number", title: "Wrote", css: "jsGrid_Body", headercss: "jsGrid_Head", width: 21, sorter: "number", itemTemplate: function (value) { return FormatDuration(value); } }
        ]
    });
}

【问题讨论】:

  • 你的 jsGrid_Head css 中是否碰巧有一些隐藏文本字段的东西,也许?旁注,您可以只返回 $.ajax 而不是 $.Deferred 额外步骤,只要您还删除了 .done。
  • 查看生成的 HTML/CSS,TR 和 TD 存在于过滤器行/单元格中,但 TD 中没有任何内容。我取出所有与 JS Grid 相关的自定义 CSS 只是为了当然,但仍然没有。以下是它生成的内容: .. 我在尝试不同的示例时弄乱了客户端过滤,此时我'我只是要手动定义一些字段来过滤网格上方。我认为它必须与包含的库版本等有关。他们的演示很简单,但他们使用了许多小的本地包含
  • 我可能应该尝试完全按照演示的方式进行操作,并使用所有包含的 JS 和 CSS 库,而不是 1 个 CDN 托管库。接下来我将使用 JqGrid。我是在此之前真的很喜欢这个 JsGrid。最终我需要我的新雇主购买 Kendo UI :-)
  • 我已经在我的页面中尝试了你的代码来执行此操作,甚至将你的网格基本上剥离,它仍然没有显示过滤,所以到目前为止我很难过。
  • 是的,这很奇怪,看起来应该很简单,但是,没有骰子。感谢您的帮助并尝试运行它,有助于证明包含理论到.. thnx 再次..

标签: javascript jquery html css jsgrid


【解决方案1】:

也许这个话题已经打开了很长时间。但我遇到了同样的问题,使用 heading: true 属性对我有用

【讨论】:

    【解决方案2】:

    好的,所以它实际上很简单,也很愚蠢。它是如此愚蠢和简单,以至于很容易错过。将字段中的类型声明更改为全部小写。

    类型:“数字” >> 类型:“数字”

    类型:“文本” >> 类型:“文本”

    开发人员应该不区分大小写,但开发人员懒惰......

    【讨论】:

    • 哎呀,我的男人! .. 呃,我很确定我从复制/粘贴开始,这就是它的方式:-) 非常感谢! . id up 投票,但看起来我在这里还很菜鸟。 ;- |
    • 好吧,也许你会得到更多的赞成票,然后就可以投票了。如果您获得足够的选票,您也可能能够接受这个答案。
    • FWIW,您可能想在 JSGrid GitHub 页面上将此作为错误提出。这不完全是一个错误,但是当文本属性不是小写时出现意外结果是非常愚蠢的。我知道这是 HTML 属性的要求,但它仍然很愚蠢,IMO。
    • 是的,它可能被认为是一种增强.. JavaScript 是一种区分大小写的语言 yano 但就像你说的那样,它是一个属性,值是在 JsGrid Libs 中定义的“类型”,而不是语言类型或任何东西..“FWIW”和“IMO”代表什么?
    • FWIW:物有所值。 IMO:在我看来。
    猜你喜欢
    相关资源
    最近更新 更多
    热门标签