This is a migrated thread and some comments may be shown as answers.

Select based on dataItems instead of selectors

1 Answer 38 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Miguel
Top achievements
Rank 1
Miguel asked on 26 Aug 2014, 10:30 PM
I'm selecting some items programmatically by using kendoGrid.select. It works fine, but I find the restriction to only select based on DOM elements (or jQuery expressions) a bit restrictive. This is important specially when using frameworks like Ember or patterns like MVVM where you work with the data and not directly with the DOM. I have the following code to make it work, but it would be nice if I could just call kendoGrid.select('selectedMedication') instead of having to find the corresponding element myself. Any idea if that's possible? 

```
 var kendoGridObject = this.get('kendoGridObject'),
            selectedMedication = this.get('selectedMedication'),
            dataItems = kendoGridObject.dataItems(),
            selectedDataItem = dataItems.findBy('_originalObject', selectedMedication),
            selector = 'tr[data-uid="' + selectedDataItem.uid + '"]';
        // finally from the data-uid we have our jquery selector
        kendoGridObject.select(selector);
}.observes('selectedRow')
```

1 Answer, 1 is accepted

Sort by
0
Dimiter Madjarov
Telerik team
answered on 28 Aug 2014, 11:27 AM
Hello Miguel,


By design the Grid selection operates only over DOM elements. Indeed using the uid property of the items and retrieving the corresponding row is the correct workaround in the current scenario.

Regards,
Dimiter Madjarov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
General Discussions
Asked by
Miguel
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Share this question
or