简体   繁体   English

用Kendo网格链接列过滤器

[英]Chaining column filters with Kendo grid

How do you cause the dropdown values in the City column to filter based on which State is selected so that only the cities within that state are shown? 如何使“城市”列中的下拉值根据选择的州进行过滤,以便仅显示该州内的城市?

function cityFilter(element) {
    element.kendoDropDownList({
        dataSource: {
            transport: {
                read: "http://localhost:8888/City.php",
                dataType: "json"
            },
            schema: {
                data: "data"
            }
        },

        dataTextField:"City",
        dataValueField:"City",
        optionLabel: "--Select Value--"
    });
}

function stateFilter(element) {
    element.kendoDropDownList({
        dataSource: {
           transport: {
                read: "http://localhost:8888/State.php",
                dataType: "json"
            },
            schema: {
                data: "data"
            }
        },

        dataTextField:"State_Long",
        dataValueField:"State_Long",
        optionLabel: "--Select Value--"
    });
}

This is how I managed to do mine: 这就是我设法做的事情:

    function deviceFilter(element) {
    element.kendoDropDownList({
        dataTextField: "DeviceTypeName",
        dataValueField: "DeviceTypeName",
        dataSource: {
            transport: {
                read: "@Url.Action("DeviceTypes", "Device")"
            }
        },
        optionLabel: "--Select Value--",
        change: deviceFilterChange
    });
}

function deviceFilterChange() {
    var value = this.value(),
          grid = $("#DevicesRadGrid").data("kendoGrid");

    if (value) {
        grid.dataSource.filter({ field: "DeviceType", operator: "eq", value: value });
    } else {
        grid.dataSource.filter({});
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM