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

How to add parameter on delete event

6 Answers 135 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.
Chris
Top achievements
Rank 1
Chris asked on 28 Oct 2010, 03:20 PM
Hi,
    I am using ajax binding for my grid. There's a parameter generated by javascript and I need to pass it to server when user invokes a delete action. I use client event OnDelete and set e.data = { productId: currentModel.Id } in the handler. But when I watch the request body in Fiddler I found the "productId" is not included in post body. I use this method in databinding handler and it works fine. But it seems not ok in delete handler.
   Could someone tell me how to pass a parameter along with delete request?
   Thanks a lot.

6 Answers, 1 is accepted

Sort by
0
Ian
Top achievements
Rank 1
answered on 03 Dec 2010, 09:57 PM
I'm having the same issue with the OnSave event of the grid, could someone please let us know if this is a bug?
0
Rosen
Telerik team
answered on 06 Dec 2010, 09:33 AM
Hi Ian,

In order to modify the posted values, when saving the grid's edit form, you should use the values property of the event's argument object . For more detailed information, please refer to this help article (under OnSave section).

Greetings,
Rosen
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Casey
Top achievements
Rank 1
answered on 13 May 2011, 03:03 PM
Hi,

Did this post adequately resolve the issue?  For me at least (and based on the linked-to documentation) onSave doesn't get fired for a delete.
0
Matt
Top achievements
Rank 1
answered on 16 Nov 2011, 04:54 AM
Adding parameters works fine using the e.values argument for saving and updating, but any additional parameters placed in e.values or e.data (onDelete function) are still ignored.  How do i pass additional parameters through to the onDelete action?
0
Matt
Top achievements
Rank 1
answered on 06 Dec 2011, 02:07 AM
After a bit of trial and error, i found the best way to add additional parameters to the delete function was to include them in the datakeys collection.  So along with storing the id of the record, i also put the id of the category the record belongs to so that i can reload the grid with the correct category filter.
0
Niyati
Top achievements
Rank 1
answered on 07 Dec 2011, 08:22 AM
Hi

I'm new to Telerik controls, so I'm probably missing something.

I have used grid control with server binding, but unable to fire the action defined for Delete.  

I have put breakpoints in the grid methods but there is no indication they fire.

Here is my View:

   "DisplayProducts" is List<Products>

@using (Html.BeginForm())
{
   @(Html.Telerik().Grid(Model.DisplayProducts)
        .Name("selected-product-grid")
            .DataKeys(keys =>
           {
               keys.Add(x => x.Id);
          })
  .Columns(columns =>
  {
  columns.Bound(x => x.Name);
  columns.Command(c => c.Delete());
    })
 .DataBinding(db => db.Server()
 .Delete("ProductAddPopupDelete", "Discount", new { discountId = Model.DiscountId }))
 .Footer(false)
 )
}

Here is my controller action method :

[HttpPost, GridAction]
public ActionResult ProductAddPopupDelete(int id, int discountId, GridCommand command)
{
    var discount = _discountService.GetDiscountById(discountId);
    if (discount != null)
    {
        //TODO: perform some action
    }
    return ProductAddPopup(discountId);
}

What am I missing from making these actions fire?

Thanks
Tags
Grid
Asked by
Chris
Top achievements
Rank 1
Answers by
Ian
Top achievements
Rank 1
Rosen
Telerik team
Casey
Top achievements
Rank 1
Matt
Top achievements
Rank 1
Niyati
Top achievements
Rank 1
Share this question
or