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

Expand/Collapse RadGrid Edit Template using JavaScript

2 Answers 98 Views
Grid
This is a migrated thread and some comments may be shown as answers.
johnv
Top achievements
Rank 2
johnv asked on 01 Sep 2010, 02:31 PM
Hey Telerik Community,

I have been asked to implement Expand/Collapse row editing using the OnRowClick client event (ex: click the row once it expands, click the row again it collapses). I have the row expand working nicely.

Ex. Expand:
function RowClick(sender, eventArgs) {
    sender.get_masterTableView().editItem(eventArgs.get_itemIndexHierarchical());
}

What is its counterpart for collapsing the row using the same click event? I imagine it will have some decision logic, but am not sure what the editItem should do or what the decision tree should contain.

Ex. Expand/Collapse?:
function RowClick(sender, eventArgs) {
    if(?????)
    {
        sender.get_masterTableView().editItem(eventArgs.get_itemIndexHierarchical());
    }
    else
    {
        sender.get_masterTableView().editItem(eventArgs.get_itemIndexHierarchical()).????;
    }
}

Has anyone performed this same task? If so what was the solution?

Thanks in advance,

John

2 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 1
answered on 02 Sep 2010, 09:02 AM
Hello John,


You could access the grid row's indexes using "sender._editIndexes" property in OnRowClick event. Now check EditIndexes values with the clicked row index, if it matches then close the editform using cancelUpdate method.

I hope this suggestion helps.


-Shinu.
0
johnv
Top achievements
Rank 2
answered on 02 Sep 2010, 09:07 PM
Thanks for the clues. It turned out to be exactly what I suspected with the simple addition of your solution. Works great.

function RowClick(sender, eventArgs) {
    var masterTable = sender.get_masterTableView();
    if (sender._editIndexes[0] == eventArgs.get_itemIndexHierarchical()) {
        masterTable.cancelUpdate(eventArgs.get_itemIndexHierarchical());
    }
    else {
        masterTable.editItem(eventArgs.get_itemIndexHierarchical());
    }
}

Tags
Grid
Asked by
johnv
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 1
johnv
Top achievements
Rank 2
Share this question
or