Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
2165
Get row index
posted

Question #1: Is $(ui.element).data("row-idx") always equals to ui.owner._rowIndex?

Question #2: Is ui.owner._rowIndex the right index to get the corresponding row from the view?

I want to be sure I will always get the right Description and Name from the view:


$(document).delegate("#MyGrid", "iggridupdatingeditrowended", function (evt, ui) {

if ($(ui.owner.element).data("level") === 0) { // It's a Parent

   var pRow = $('#MyGrid').data("igGrid").dataSource.dataView()[ui.owner._rowIndex];

   // Show category's decription
   console.log(pRow.Description);

} else { // It's a Child

   var pRow = $(ui.owner.element).parents("tr[data-container='true']").prev("tr");

   // Get parent's index
   var pViewIdx = $(pRow).data("row-idx");

   // Get children
   var cRows = $('#MyGrid').data("igGrid").dataSource.dataView()[pViewIdx].Products.Records;

   // Show the name of the edited product
   console.log(cRows[ui.owner._rowIndex].Name);
}
});

Parents Reply Children