Select based on dataItems instead of selectors

2 posts, 0 answers
  1. Miguel
    Miguel avatar
    15 posts
    Member since:
    Jul 2014

    Posted 26 Aug 2014 Link to this post

    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')
    ```

  2. Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2304 posts

    Posted 28 Aug 2014 Link to this post

    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!
     
Back to Top