AngularUI-Kendo-动态列下的筛选器未工作
创始人
2024-10-29 20:30:25
0

处理动态列时,需要在Kendo Grid初始化前准备好列数据,并在数据模型中添加列字段。此外,在列数组中添加对象时,需要设置标题、字段、筛选器和模板等属性。例如,以下是处理筛选器的示例代码:

$scope.gridOptions = {
    dataSource: {
        type: "odata",
        data: products,
        pageSize: 20
    },
    filterable: true,
    sort: { field: "ProductName", dir: "asc" },
    pageable: true,
    columns: [
        { field:"ProductName", title: "Product Name" },
        { field:"UnitPrice", title:"Unit Price", filterable: { ui: rangeSliderFilterTemplate } },
        { field:"UnitsInStock", title:"Units In Stock", filterable: true },
        { field:"Discontinued", title:"Discontinued", filterable: true }
    ]
};

function rangeSliderFilterTemplate(element) {
    element.kendoRangeSlider({
        min: 0,
        max: 200,
        step: 1,
        change: function() {
            grid.dataSource.filter({
                field: "UnitPrice", operator: "gte", value: this.values()[0]
            });
            grid.dataSource.filter({
                field: "UnitPrice", operator: "lte", value: this.values()[1]
            });
        }
    });
}

在以上示例中,我们为单位价格列添加了筛选器模板。使用kendoRangeSlider插件为滑块创建了一个模板,并在模板中使用值来筛选数据源。

同时,动态列通常需要一些逻辑来处理数据。我们可以使用ng-grid和ui-grid插件来实现完善的动态列功能。例如,在ui-grid中,我们可以将数据模型绑定到$scope.gridOptions,然后在适当的时候调用setVisible方法来切换列。具体的代码示例可以参考以下链接:

https://plnkr.co/edit/nUdRtTtYtvInyKaB?p=

相关内容

热门资讯

透视脚本"破解辅助插... 透视脚本"破解辅助插件wepoker"wepoker怎么开辅助(一直真的是有辅助神器)-哔哩哔哩1、...
透视解迷"wepok... 透视解迷"wepoker私人局辅助"切实是真的辅助方法(哔哩哔哩)1、打开软件启动之后找到中间准星的...
有消息称"wepok... 有消息称"wepoker免费钻石"德州局透视脚本(确实存在有辅助下载)-哔哩哔哩1、下载好德州局透视...
透视揭幕"wepok... 透视揭幕"wepoker买钻石有用吗"切实有辅助神器(哔哩哔哩)1、超多福利:超高返利,海量正版游戏...
据通报"wepoke... 据通报"wepoker的辅助器"德州hhpoker脚本(本来是真的辅助app)-哔哩哔哩1、进入游戏...
透视普及"aapok... 透视普及"aapoker辅助工具安全吗"都是是真的辅助器(哔哩哔哩)1、实时aapoker辅助工具安...
近期"安装不了wep... 近期"安装不了wepoker"werplan辅助软件(好像是真的辅助下载)-哔哩哔哩运安装不了wep...
透视科普"线上德州的... 透视科普"线上德州的辅助器是什么"都是是真的辅助攻略(哔哩哔哩)1、线上德州的辅助器是什么公共底牌简...
透视实锤"wpk作必... 透视实锤"wpk作必弊最怕三个东西"wepoker究竟有没有透视(都是是有辅助神器)-哔哩哔哩1、玩...
透视关于"hhpok... 透视关于"hhpoker透视脚本"一贯存在有辅助攻略(哔哩哔哩)1、金币登录送、破产送、升级送、活动...