已选择 Kendo UI 网格行来填充 select 菜单?

Selected Kendo UI grid rows to populate select menu?

我有一个 kendo 网格,其中启用了多行 selection;我正在尝试根据上述行 selection(s) 中的一些字段填充外部 select 菜单;我无处可去;这可以做到吗? Fiddle 个例子?

我查看了 this fiddle,他们根据第一个 kendo 网格中 select 编辑的内容填充了另一个 kendo 网格;我想我会构建 select 选项,例如:

$("#selectMenu").html("<option value=''></option>");

..但我不知道如何从 kendo 网格中获取 selected 数据..

该代码不是很好的 IMO,因为它只依赖于 jQuery 而不是使用网格 API。您可以使用 change event to detect row changes, get the selected rows with the select methd and the data items with the dataItem 方法。

所以你可以从这样的事情开始:

$("#states").kendoGrid({
    selectable: "multiple",
    dataSource: {
        data: usStates
    },
    change: function() {
        var that = this;
        var html = "";
        this.select().each(function() {
            var dataItem = that.dataItem(this);
            html += "<option>" + dataItem.name +"</option>";
        });
        $("#select").html(html);
    }
});

(demo)