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
486
How to use row-edit-dialog-row-template to edit a list property
posted

Hi,

I'm trying to use the row-edit-dialog of the igGrid Updating to edit an item that has a list as a property. The list entries should be displayed with their own input fields and changes should be saved back to the object.

I was trying to solve this with templates but was not able to access the list in the template. It looks as if the data is added after the templating because inside I was only able to access the header text and the datakey not the data itself. Is it possible to still get this working or will I have to create my own dialog?

If I have to create my own dialog how would you recommend that I open it and get the changes back into the grid – if possible using the Updating events of the grid just with my own dialog.

I am using Ignite UI 2014.2 and Angular with the igniteui-angular.js directives.

Any help would be appreciated.

Parents Reply
  • 23953
    Offline posted in reply to Christian

    Hello Stefan,

    On your first question. Currently there is no out of the box solution for row edit template to work with complex objects. The custom solution is to handle the rowEditDialogContentsRendered event and inject your custom input fields. Then you need to cancel the default behavior of the row edit template by canceling the rowEditDialogClosing event and manually update the grid by using the igGridUpdating.updateRow or igGridUpdating.addRow API. I didn't have time to try this approach myself. I'll work on that on Monday. However I modified your sample to make it work. You can find it attached to this forum post.
    First I handled the editRowStarting event in order to show the dialog. Inside the event I'm canceling the default behavior. Also there is a check whether the operation is adding a row or editing. I also changed the "designation" column data type to "object". This is needed in order to see the property value as an array and not string. Next I added two buttons - "Save" and "Cancel". The "Save" button calls igGridUpdating.addRow or igGridUpdating.updateRow API in order to update the data source. The "Cancel" button only closes the dialog. Last I removed the template of the designation column and replaced it with formatter function. This way I was able to call a scoped function and execute the logic you had in your template in JavaScript.

    Hope this helps,
    Martin Pavlov
    Infragistics, Inc. 

    Index2_v1.zip
Children