Search code examples
javascriptangularjskendo-uikendo-dropdown

How to refresh the kendo drop down list dynamically?


Is there anyway to refresh/update the kendo drop down list after an item is selected in the list?

Ex: I have 10 items in the list and when user selects item number 7 i don't want to see 7th item in the drop down.

$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>

Solution

  • Try this directly:

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

    Let's say we have a dropdownlist (ddl is dropdownlist). Then, we are reading the datasource. I guess the issue may be the ddl is not refreshing.

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

    So, set the cache value to false.

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