We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Submit (POST) of the entire grid

Thread ID:

Created:

Updated:

Platform:

Replies:

118650 Mar 29,2015 06:23 AM UTC Feb 2,2017 05:51 AM UTC ASP.NET MVC 5
loading
Tags: Grid
Martin
Asked On March 29, 2015 06:23 AM UTC

Hi,

I'm using the Grid (ASP.NET MVC 5), I'm trying to Post back to my controller the complete values of a Grid.


I need to use the @Ajax.BeginForm helper to submit the form.  I plan on starting with an empty grid (if that matter).


Can you please provide an simple example of doing so?  Just like 2 column, nothing fancy  I'm having a hard time!  (I can provide my code if needed).

Thanks,
Appreciated.






Ajith R [Syncfusion]
Replied On March 30, 2015 01:42 PM UTC

Hi Martin,

Thanks for using Syncfusion products.

Query: Ineed touse the @Ajax.BeginForm helper to submit the form. Can you please provide an simple example of doing so?

We suggest you to get the Grid dataSource as serialized string in the submit button click event and pass it to the controller by using hidden input element in the Ajax.BeginForm method to achieve your requirement. Please refer the below code snippet for further details.

[cshtml]

@using (Ajax.BeginForm("GetOrders", "Grid", null, FormMethod.Post))

{

@(Html.EJ().Grid<AjaxFormPostGrid.OrdersView>("Grid")

.Datasource((IEnumerable<object>)ViewBag.datasource)

.AllowPaging()

.Columns(col =>

{

-------

-------

})

)

<button type="submit" onclick="complete();">Get DataSource</button>

<input type="hidden" name="dataSource" value="" id="data" />

}

<script type="text/javascript">

function complete() {

var gridobj = $("#Grid").data("ejGrid");

var val = JSON.stringify(gridobj.model.dataSource); // Serialized the grid dataSource

$("#data").val(val); // Set the dataSource to hidden element

}

</script>

[controller]

public ActionResult GetOrders(string dataSource)

{

// Code here for deserializing the dataSource

var deserializedObj = (List<OrdersView>)Newtonsoft.Json.JsonConvert.DeserializeObject(dataSource, typeof(List<OrdersView>));

return RedirectToAction("GridFeatures");

}

For your convenience we have created a simple sample and the same can be downloaded from the belwo link.

Sample Link: http://www.syncfusion.com/downloads/support/forum/118650/AjaxFormPostGrid1793574874.zip

Please let us know if you have any concerns.

Regards,

Ajith R


Martin
Replied On March 31, 2015 06:16 AM UTC

Thanks you very much,

Exactly what I was looking for!

Ajith R [Syncfusion]
Replied On April 1, 2015 04:55 AM UTC

Hi Martin,

Thanks for your update.

We are happy to hear that your requirement has been achieved in your end.

Please get back to us if you have any other concerns.

Regards,
Ajith R


Khaled
Replied On February 1, 2017 05:02 PM UTC

it helped me too!

Ragavee U S [Syncfusion]
Replied On February 2, 2017 05:51 AM UTC

Hi Khaled, 
  
Thanks for your update. 
 
Regards, 
Ragavee U S. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;