Telerik MVC Grid: Getting the Parent Row after a ComboBox OnChange event during inline editing
I have an parent child Telerik MVC grid. In the child grid I have a 开发者_开发知识库ComboBox. In the OnChange event of that comboBox, I need to lookup the value of something and populate another column in this edited row. If I already have child rows in this child grid, the following code will work to get the dataItem object of the parent row. However, if there are no child rows (I am just adding the first row), this does not work.
function ComboBox_OnChangeg(e)
{
var comboID = $("#combo").data('tComboBox').value();
var parentID = row.closest('.t-grid').data('tGrid').data[0].ParentID; // <--- IS NOT AN OBJECT!!!
// ajax call, blah blah
}
With no child rows in the child grid, how can I get the parent dataItem object and get the value of a column of the parent row?
Remember: This is the OnChange event of a ComboBox in a grid during in-line editing. This is NOT the OnEdit event of the grid.
Steve
Inspecting the page source, I discovered that the detail grid is rendered in a whole-table-spanning cell placed on the tr following the master row tr. So:
- get closest
trancestor with classt-detail-row - find the nearest previous sibling
trwith classt-master-row pass the
trfound on step 2 to thedataItemclient side method of the master gridvar $masterRow = $comboElement.closest('tr.t-detail-row').prev('tr.t-master-row');var masterData = $('#LieuLeconGrid').data('tGrid').dataItem($masterRow);
加载中,请稍侯......
精彩评论