如何动态刷新kendo下拉列表?

时间:2016-01-06 16:35:44

标签: javascript angularjs kendo-ui kendo-dropdown

在列表中选择项目后,是否还要刷新/更新kendo下拉列表?

例如:我在列表中有10个项目,当用户选择项目编号7时,我不想在下拉列表中看到第7个项目。

$scope.macAddressSource = new kendo.data.DataSource({
  batch: true,
  transport: {
    read: deviceSvc.getEncodersReadyForCommissioning
  },
  //schema: {
  //    total: "totalItems",
  //    data: "items"
  //},
  serverPaging: true
});

$scope.updateMacAddress = function() {
  $scope.macAddressSource.remove($scope.macAddress);
  $scope.macAddressSource.sync();
};

$scope.macAddressOptions = {
  optionLabel: {
    id: null,
    description: $rootScope.$translate.instant("- None -")
  }
};
<select kendo-drop-down-list="widgets.deptdropdown" name="dropdown-macAddress" k-data-source="macAddressSource" k-data-text-field="'description'" k-data-value-field="'id'" tabindex="4" k-options="macAddressOptions" ng-model="macAddress" class="col-md-12 ph0 mb-sm"
data-qaid="ddl-encodermacAddress"></select>

1 个答案:

答案 0 :(得分:0)

直接试试:

&#13;
&#13;
$("#ddl").data("kendoDropDownList").dataSource.read();
&#13;
&#13;
&#13;

我们假设我们有一个下拉列表(ddl是下拉列表)。然后,我们正在阅读数据源。我猜这个问题可能是ddl并不令人耳目一新。

&#13;
&#13;
$("#ddl").data("kendoDropDownList").dataSource.read();
&#13;
&#13;
&#13;

因此,请将缓存值设置为 false

&#13;
&#13;
read: {
    url: <<"url">>,
    cache: false
}
&#13;
&#13;
&#13;