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

[Solved] Row Select While Editing

2 Answers 167 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Patrick
Top achievements
Rank 1
Patrick asked on 08 Feb 2012, 02:30 PM
I've implemented onRowSelect for an ajax bound grid.  When I click on a row, I navigate to the details page of my row and everything works great.  However, if I first click the edit command to put the row in edit mode, and then click on a cell, the RowSelect event is raised and I again navigate to the details page.  While in the RowSelect handler is there a way to detect that the grid/row is in edit mode or do i need to track this myself using OnCommand?  Any other suggestions?
Thanks

2 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 13 Feb 2012, 08:29 AM
Hello Patrick,

You could determine if the selected row is in edit mode by checking if it has the "t-grid-edit-row" class e.g.
function onRowSelect(e) {
    if ($(e.row).is('.t-grid-edit-row')) {
         
    }      
}
Using a custom command to navigate to the details page will also help to avoid this behaviour.

All the best,
Daniel
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Mauro
Top achievements
Rank 1
answered on 13 Sep 2012, 02:15 PM
That solution wasn't work, because OnRowSelect never handle onEdit event, OnCommand neither (in telerik's documentation says that it's possible: "The OnCommand event is raised when the user triggers a command (built-in or custom)", but lines below says: "Important: The OnCommand event is triggered only for Ajax enabled custom commands.").

I encountered a solution for this:

function onEdit(e) {
        //Select current row editing:
        selectSingleEditingRowGrid($(this)); // $(this) is same to do: $('#GridName')


/* Clear selected-rows grid:
----------------------------------------------------------*/
function resetSelectedRowsGrid(idGrid) {
    //reset selected row:
    $('#' + idGrid).data('tGrid').$rows().removeClass('t-state-selected');
}


/* Select a single row in a grid:
----------------------------------------------------------*/
function selectSingleRowGrid(idGrid, tr) {
    //reset selected row:
    resetSelectedRowsGrid(idGrid);


    tr.className = 't-state-selected';
}


/* Select a single row editing in a grid:
----------------------------------------------------------*/
function selectSingleEditingRowGrid(gridContent) {
    var tr = gridContent.data('tGrid').$tbody.find('tr.t-grid-edit-row')[0];
    selectSingleRowGrid(gridContent.attr('id'), tr);
}


I hope that help you,

Dorso
Tags
Grid
Asked by
Patrick
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Mauro
Top achievements
Rank 1
Share this question
or