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

Can we add a selectable=manual mode for the grid

2 Answers 151 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:19 PM
Right now the KendoGrid support different selection modes (none, rows, cells and multiple). I would like to define a manual mode and a multiple manual mode. 

Basically we need to set the selected a row programmatically, but prevent it from being selected when the user clicks the row or the cell. We have a link on first column and other ways to select an element outside the grid, but for all of our other columns, we need the user to be able to click them to select text or interact with other elements without causing a selection of the row. Selecting manually doesn't work unless I set selectable=row, but that has the undesired behavior selecting when touching any cell of a row. 

Can this be added to KendoGrid? 

2 Answers, 1 is accepted

Sort by
0
Miguel
Top achievements
Rank 1
answered on 26 Aug 2014, 11:27 PM
I found a hacky way of doing this by replacing the private `_allowSelection` function on selectable. See example below: 

 _setSelectionMode: function () {
        if (this.get('selectable') === 'manual') {
            // NOTE: There might be a way to support a manual mode
            // see: http://www.telerik.com/forums/can-we-add-a-selectable=manual-mode-for-the-grid
            this.get('kendoGridObject').selectable._allowSelection = function () {
                return false;
            };
        }
    },



0
Dimiter Madjarov
Telerik team
answered on 28 Aug 2014, 11:08 AM
Hi Miguel,


Custom modifications to the Kendo UI source code are not supported. As a sample approach in the current case you could disable the Grid selection and manually add the k-state-selected class the rows, that should be selected, instead of using the select() method of the Grid API.
E.g.
grid.tbody.find("tr:first").addClass("k-state-selected");

In order to retrieve the selected rows in the current case, you could again use the k-state-selected class.
E.g.
grid.tbody.find("tr.k-state-selected");

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
Miguel
Top achievements
Rank 1
Dimiter Madjarov
Telerik team
Share this question
or