lost rebind with autocomplete

3 posts, 1 answers
  1. Lisa
    Lisa avatar
    7 posts
    Member since:
    Mar 2013

    Posted 05 May 2015 Link to this post

    Hi,

    Here is a multiselect which I want to change its value on the change event. It pre-select three options, when mouse click the dropdown and pick an extra one, it will reset it back to two options. Now click the dropdown, use autocomplete (key in E which shows option EEE) to choose an extra option, the multiselect become empty. Please see the file attached. How to rebind it with autocomplete?

            <select kendo-multi-select="productSelect" k-options="selectOptions" ng-model="selectedIds"
             k-on-change="isChanging(kendoEvent)"
            ></select>
            <button data-kendo-button data-ng-click="reset()">Reset</button>

     

    $scope.selectOptions = {
                placeholder: "Select products...",
                dataTextField: "ProductName",
                dataValueField: "ProductID",
                valuePrimitive: true,
                autoBind: false,
               dataSource: {
                      data: [
                        { ProductName: "AAA", ProductID: 1 },
                        { ProductName: "BBB", ProductID: 2 },
                        { ProductName: "CCC", ProductID: 3 },
                        { ProductName: "DDD", ProductID: 4 },
                        { ProductName: "EEE", ProductID: 5 }
                      ]
                }
            };
       
            $scope.selectedIds = [ 1, 2, 3 ];
       
            $scope.reset = function(){
              $scope.selectedIds = [ 1, 2, 3 ];
            }
     
            $scope.isChanging = function(kendoEvent){
              $scope.selectedIds = [ 3, 5 ];
            }  

    Thanks,

    Lisa

  2. Answer
    Georgi Krustev
    Admin
    Georgi Krustev avatar
    3706 posts

    Posted 08 May 2015 Link to this post

    Hello Lisa,

    The described behavior is expected. The widget cannot select items that does not present in its data source, which is the case when the source is filtered. If you would like to update values on change, then you will need to clear the filter first:
    $scope.isChanging = function(kendoEvent){
       kendoEvent.sender.dataSource.filter({});
       $scope.selectedIds = [ 3, 5 ];
    }

    Regards,
    Georgi Krustev
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  3. Kendo UI is VS 2017 Ready
  4. Lisa
    Lisa avatar
    7 posts
    Member since:
    Mar 2013

    Posted 27 May 2015 in reply to Georgi Krustev Link to this post

    Thanks Georgi, this fixed it.
Back to Top