Hi,
I am having a problem with adding new child records. The problem is linking these child records to their parent. I am binding my whd to a generic list of objects, each of which may have child objects.
In the child object, I have a property called ParentID, which allows me to link exisitng child rows/objects to the parent rows/objects. However, the property is empty for new rows. I cant think of anything I can utilize in the row_adding event for the child row.
Hi vimaljonn,
I can think of two approaches, one of which I have tried. The first is to have a column in your child grids for the parent Id value. You can hide this column and in the row adding client event, simply set it to the correct value. Then you should be fine.
Another option would be to handle the row adding server event and try adding another key/value pair to eventArgs.Values. This would contain your ParentId / val.
Let us know if you need more help.
regards,David Young
Hi David,
Thanks for your reply. I do have a column for the Parent ID in my child row. That is how I am able to update the child row. But for the new rows, this Parent ID is empty. It only has the ID for existing child rows. If you had tried the methods you described successfully, could you please outline the steps?
Best,
Marshal
Sorry never mind David, it worked! thanks much!
I included the script that you posted but I get the following javascript error: "'grid' is undefined" when I tried debudding it.
I put in the funtion on on my markup and here's where I am calling it:
If you have your bands defined at design time, simply define the row adding behavior in the child band and set editing core rowAdding client event to the handler. You could also attach it to the grid view's behavior if you have it there with inheritance, but be sure to not use the parent row if it is null.
-Dave
David,
Sorry, how do I wire up the javascript to the grid? Or which one, to be more specific.
Yes, Dave, you are right. Let me give this a try and will get back to you. Thanks much!