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

Getting Parent Row Client-Side

4 Answers 90 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.
Kevin
Top achievements
Rank 1
Kevin asked on 28 Sep 2011, 06:16 PM
These Telerik MVC extensions are great.  The documentation is good and the forums are helpful.  However, I think it would seriously reduce the amount of questions asked on these forums if the documentation was expanded.  Specifically the Grid's "Client API and Events".  

I am trying to get the value of a column in the parent row of a child's onEdit event.  How would I achieve that?  

e.target.parentNode.parentNode.parentNode.innerHTML gives me table row of the parent row.  I now need to parse this to get the column data I want.  Someone know of a more elegant solution?

Steve

4 Answers, 1 is accepted

Sort by
0
Accepted
cp
Top achievements
Rank 1
answered on 29 Sep 2011, 05:16 AM
You may want to try something like this inside your OnEdit handler:

var grid = $('#MasterGridName').data('tGrid');
var masterRow = $(e.form).closest('.t-detail-row').prev();
var parentDataItem = masterRow.closest('.t-grid').data('tGrid').dataItem(masterRow);
0
Kevin
Top achievements
Rank 1
answered on 30 Sep 2011, 06:51 PM
That worked!! Thanks!  I will need to also access the dataItem of a "grandparent" of a grandchild row.  I will see if I can figure it out based on what you sent me.  If you can think of it on off the top of your head, please post it here.

Thanks, 
Steve
0
Kevin
Top achievements
Rank 1
answered on 30 Sep 2011, 07:23 PM
So that worked, however, I don't know how to get the grandparent. .t-detail-row seems to be the key to get the master row: 

$(e.form).closest('.t-detail-row').prev();

But now that I have the master row (the dad in a grandpa-dad-son relationship), it won't help me get it's parent (the grandpa).  I need to check a value in the top level master row.  I could do it with ajax, but I think it will be too slow for an onEdit event and besides, the data is there.

Someone please help me find grandpa!

Steve

0
MICHAEL
Top achievements
Rank 1
answered on 16 Apr 2012, 11:12 PM
Hello, I'm trying to get the master row but every time i use that code I get on the following line that dataitem is null or undefined.  I have a master row with a tab and a child row within the tab.

var parentDataItem = masterRow.closest('.t-grid').data('tGrid').dataItem(masterRow);

Also I see you have the following line defined but never used:

var grid = $('#MasterGridName').data('tGrid');

Am I not properly defining something.  Where in the code you posted is the var grid used?

var grid = $('#MasterGridName').data('tGrid');
var masterRow = $(e.form).closest('.t-detail-row').prev();
var parentDataItem = masterRow.closest('.t-grid').data('tGrid').dataItem(masterRow);
Tags
Grid
Asked by
Kevin
Top achievements
Rank 1
Answers by
cp
Top achievements
Rank 1
Kevin
Top achievements
Rank 1
MICHAEL
Top achievements
Rank 1
Share this question
or