This is a migrated thread and some comments may be shown as answers.

[Solved] Ajax Delete: Add Route Values

1 Answer 120 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
jfkrueger
Top achievements
Rank 1
jfkrueger asked on 12 Jun 2012, 09:18 PM

I have a grid in an edit template for another grid. When a row is deleted from the grid in the edit template, I need to pass the data key for the row that is deleted (to remove the row), which is no problem but I also need to pass the ID of the parent item (data key in parent grid). I have tried a few things to no avail:

Hooking up to onDelete event and trying to add in javascript:

function onImageDelete(e) {
             
    e.data = { inventoryItemId: key };
 
}

This doesn't work becuase e.data is null.

Then I tried adding it on teh .DataBinding declaration:

.DataBinding( dataBinding => dataBinding.Ajax()
    .Select( "BindImages", "CatalogAdministration" )
    .Insert( "ImageCreate", "CatalogAdministration" )
    .Delete( "ImageDelete", "CatalogAdministration", new { inventoryItemId = Model.InventoryItemId } ))

But the value of the Model.InventoryItemId is always 0 for some reason - breakpoints are only hit when the parent grid is loaded, not when the edit button is clicked so at the time the code reaches the breakpoint there is no model loaded up into the grid.

Any help?

1 Answer, 1 is accepted

Sort by
0
jfkrueger
Top achievements
Rank 1
answered on 12 Jun 2012, 09:22 PM
Found it immediately after posting this...

Here is the anwer:
function onImageDelete(e) {
 
    e.values.inventoryItemId = key;
 
}

 

 

 

 

 

Tags
Grid
Asked by
jfkrueger
Top achievements
Rank 1
Answers by
jfkrueger
Top achievements
Rank 1
Share this question
or