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

How to refresh the kendo drop down list dynamically?

在列表中选择项目后,refresh/update 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>

直接试试这个:

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

假设我们有一个下拉列表(ddl 是下拉列表)。然后,我们正在读取数据源。我想问题可能是 ddl 没有刷新。

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

因此,将缓存值设置为false

read: {
    url: <<"url">>,
    cache: false
}