Can we add a selectable=manual mode for the grid

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

    Posted 26 Aug 2014 Link to this post

    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. Miguel
    Miguel avatar
    15 posts
    Member since:
    Jul 2014

    Posted 26 Aug 2014 in reply to Miguel Link to this post

    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;
                };
            }
        },



  3. Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2304 posts

    Posted 28 Aug 2014 Link to this post

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