Quantcast
Channel: Telerik Forums RSS
Viewing all articles
Browse latest Browse all 84751

Programmatically adding / removing selections

$
0
0

Hi

I've been working with the MultiSelect widget for a while now but this has led to a few questions....

Is there anyway to add or remove selections programmatically? I've implemented the following code in the select event but having tried lots of different methods, as suggested in the forums, I cannot get this to work (e.g. clearing the datasource filter and setting value seems to be the most popular). My multiselect is remote bound. My onSelect event is shown below.

Is there a better way of getting the dataItem rather than how I'm doing it in the first line?

Thanks

Keith

private checkSelection(e: kendo.ui.MultiSelectSelectEvent) {
            
    vardataItem = e.item.data().$$kendoScope.dataItem;
    varhidSelected = dataItem.hid;
    e.preventDefault();
    //check to see if adding this will change anything currently selected     
    _.find(<Array<any>>this.msSelector.dataItems(), (s) => {
          if(s.hid != hidSelected) {
              //check to see if item's ancestor has been selected
              if(_.startsWith(hidSelected, s.hid)) {
                   this.dialogService.showYesNo('Confirm selection',
                            'Adding <span class="text-bold">'+ dataItem.name + '</span> will remove <span class="text-bold">'+ s.name + '</span>. Do you want to continue?').promise.then((r) => {
                     if(r) {
                          //remove parent                                         
                     }
                     else{
                          //remove new selection
                     }
                     return;
                 });
             }
          }
     });
}

Viewing all articles
Browse latest Browse all 84751

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>