使用Kendo网格链接列过滤器

时间:2013-05-05 20:33:20

标签: javascript sql html5 kendo-ui kendo-grid

如何使“城市”列中的下拉值根据选择的状态进行过滤,以便仅显示该州内的城市?

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--"
    });
}

1 个答案:

答案 0 :(得分:0)

这就是我设法做到的事情:

    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({});
    }
}