kendo multiselect选项属性集

时间:2014-01-30 12:15:09

标签: javascript jquery kendo-ui

我正在尝试Kendo多选演示。

var multi = $("#multiselect").kendoMultiSelect({
  dataSource: [
    { id: 1, name: "Apples" },
    { id: 2, name: "Oranges" }
  ],
  dataTextField: "name",
  dataValueField: "id",
}).data("kendoMultiSelect");

在其中,如果option,我想设置attribute元素selected value = "2"
比如$('option[value=2]').attr('selected','selected');
知道我怎么能这样做吗?

1 个答案:

答案 0 :(得分:0)

将数据绑定事件添加到multiselect

function MultiSelectDataBound()
{
  var multiSelect = $("#multiselect").data("kendoMultiSelect"),
  multiSelect.dataSource.filter({}); //clear applied filter before setting value
  multiSelect.value(2);
}

或者您可以创建一个文本框和按钮添加一个单击的事件并从文本框中获取值

function btnClicked()
{ 
   var multiSelect = $("#multiselect").data("kendoMultiSelect"),
   multiSelect.value($("#textbox").val().split(","));
}

For more information abot MultiSelect