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

[Solved] Batch Editing return GridModel

4 Answers 61 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jeff Kershner
Top achievements
Rank 1
Jeff Kershner asked on 29 Dec 2011, 07:06 PM
After my batch editing is done and the database is updated, I need to return the View that my grid is bound to. 

[AcceptVerbs(HttpVerbs.Post)]
[GridAction]
public ActionResult _SaveBatchEditing([Bind(Prefix = "inserted")]IEnumerable<SpendDetail> insertedRecords,
    [Bind(Prefix = "updated")]IEnumerable<SpendDetail> updatedRecords,
    [Bind(Prefix = "deleted")]IEnumerable<SpendDetail> deletedRecords)
{
    if (!Equals(updatedRecords, null) && updatedRecords.Count() > 0)
    {
        // Preform the updates
        this.SpendService.UpdateSpendDetails(updatedRecords.ToList());
 
        // Audit track who made the changes
    }
 
    return View(new GridModel());
}

The problem is that I need all the parameters on the page (html controls: startDate, endDate, spendVendorID, spendProductID), to call into my service to get that data.

Is there a way to return what ever the current view of the grid without getting the data from my database again?

If I have to get the data from my database, is there a way to get the value of the HTML controls in the _SaveBatchEditing function above?



4 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 30 Dec 2011, 11:51 AM
Hello Jeff,

Additional parameters can be passed to the Save action method by attaching a handler to the Grid's client-side OnSubmitChanges event and assigning them to the event argument's values property. For example:
function onSubmitChanges(e) {
    e.values.startDate = $("#startDate").val();
    e.values.endDate = $("#endDate").val();
}

The currently displayed data of the Grid is available through the data property of the client-side object and I guess it could be send to the Save action. However, this is error prone and I wouldn't recommend it.


Kind regards,
Daniel
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
0
Jeff Kershner
Top achievements
Rank 1
answered on 30 Dec 2011, 05:04 PM
Exactly what I needed, thanks!
0
Jeff Kershner
Top achievements
Rank 1
answered on 30 Dec 2011, 05:38 PM
Just out of curiosity, in the onSubmitChanges method, I tried the following without success:

e.values = { parm1:'Hello',parm2:'World!' };

The server side always shows param1 and param2 as null.  Any idea why this doesn't work?
0
Petur Subev
Telerik team
answered on 02 Jan 2012, 09:52 AM
Hi Jeff,


To successfully send additional values to the controller when SubmitChanges occurs use the following syntax:
e.values.param1='Hello';
e.values.param2='World!';


Kind regards,
Petur Subev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
Tags
General Discussions
Asked by
Jeff Kershner
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Jeff Kershner
Top achievements
Rank 1
Petur Subev
Telerik team
Share this question
or