【问题标题】:kendo ui grid filter empty剑道 ui 网格过滤器为空
【发布时间】:2013-12-19 22:38:32
【问题描述】:

我正在使用 Kendo UI 网格(不是 MVC)并且我正在尝试启用过滤。我只是使用默认过滤(Filtering: true),我得到空的下拉菜单。我过去曾使用过它,我认为默认包括 Starts withIs equal to 之类的东西。

这是我的网格代码:

$("#LogGrid2").kendoGrid({
    dataSource: logGridDataSource,
    columns: [{
        field: "CreateTime",
        headerAttributes: { style: "font-weight: bold; width: 10%;" },
        title: "Log Time",
        template: '#= kendo.toString(CreateTime, "MM/dd/yyyy hh:mm:ss") #',
        editable: false,
        attributes: { style: "width: 10%;" }
    }, {
        field: "LookupName",
        headerAttributes: { style: "font-weight: bold; width: 15%;" },
        title: "Lookup Value",
        editable: false,
        attributes: { style: "width: 15%;" }
    }, {
        field: "LogType",
        headerAttributes: { style: "font-weight: bold; width: 8%;" },
        title: "Type",
        editable: false,
        attributes: { style: "width: 8%;" }
    }, {
        field: "LogMessage",
        headerAttributes: { style: "font-weight: bold; width: 18%;" },
        title: "Message",
        editable: false,
        attributes: { style: "width: 18%;" }
    }, {
        field: "FileName",
        headerAttributes: { style: "font-weight: bold; width: 12%;" },
        title: "FileName",
        editable: false,
        attributes: { style: "width: 12%;" }
    }, {
        field: "LogNumber",
        headerAttributes: { style: "font-weight: bold; width: 7%;" },
        title: "Quantity",
        editable: false,
        attributes: { style: "width: 7%;" }
    }, {
        field: "LogExtraText",
        headerAttributes: { style: "font-weight: bold; width: 15%;" },
        title: "Opt Text One",
        editable: false,
        attributes: { style: "width: 15%;" }
    }, {
        field: "LogExtraText2",
        headerAttributes: { style: "font-weight: bold; width: 15%;" },
        title: "Opt Text Two",
        editable: false,
        attributes: { style: "width: 15%;" }
    }],
    selectable: {
        mode: "single"
    },
    sortable: true,
    groupable: true,
    scrollable: true,
    filterable: true,
    change: gridRowSelected
});

这是我的过滤器框的样子:http://i.imgur.com/EzVbjue.jpg

这是数据源的代码

var logGridDataSource = new kendo.data.DataSource({
    transport: {
        read: {
            url: baseUrl + "/Home/GetLogMessages?AppID=" + AppID + "&StartDate=" + StartDate + "&EndDate=" + EndDate + "&LookupID=" + LookupID + "&Type=" + LogType + "&LogCode=" + LogMessage,
            dataType: "json",
            cache: false
        }
    },
    schema: {
        model: {
            id: "LogID",
            fields: {
                LookupName: { type: "String" },
                CreateTime: { type: "Date" },
                LogType: { type: "String" },
                LogMessage: { type: "String" },
                LogNumber: { type: "Number" },
                FileName: { type: "String" },
                LogExtraText: { type: "String" },
                LogExtraText2: { type: "String" }
            }
        }
    }
});

我也尝试过配置可过滤参数,但这也不起作用。过去,我只是使用默认值。以下是我对 Filterable 选项的尝试。

filterable: {
    extra: false,
    operators: {
        string: {
            startswith: "Starts with",
            eq: "Is equal to",
            neq: "Is not equal to"
        }
    }
}

【问题讨论】:

  • dataSource 架构是什么样的?
  • 好的,让我发布数据源的代码。

标签: user-interface filter grid kendo-ui


【解决方案1】:

更改您的架构 -> 模型 -> 字段 -> 类型为小写“数字”、“日期”和“字符串”。

查看示例http://jsbin.com/UBaNuBAY/1/edit

【讨论】:

  • 谢谢!修复了问题。这让我发疯了,因为网格中的其他一切都正常运行。
  • 太棒了!我们之前的代码在这里使用了“datetime”而不是“date”——显然是错误的,但没有任何效果,因为这些日期列没有用作过滤器。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-19
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多