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
How to set foreign key?
posted

I have a two level grid, child rows have a column for the foreign key (CategoryId), after a child row is added I want to set its value (it is done automatically when the parent row already exist but it doesn't if parent is new too), for example:

$(document).delegate("#MyGrid", "iggridupdatingrowadded", function (evt, ui) {
   var parentRow = $(ui.owner.element).parents("tr[data-container='true']").prev("tr");
   var parentKey = $(parentRow).data("id");
   ui.values["CategoryId"] = parseInt(parentKey);
}

The problem with this is that the value is null when it is accessed with dataview.

How to set the value for a foreign key and then see it with dataview?


BTW, I have tried this too:

$(document).delegate("#MyGrid", "iggridupdatingrowadded", function (evt, ui) {
   var parentRow = $(ui.owner.element).parents("tr[data-container='true']").prev("tr");
   var parentRowGrid = $(parentRow).closest("table");
   var parentKey = $(parentRow).data("id");
   if (parentRowId != undefined) {
      $($(parentRowGrid.context).attr("id")).igGridUpdating("setCellValue", ui.values["Id"], "CategoryId", parseInt(parentKey));
   }
}