BoldSignEasily embed eSignatures in your .NET applications. Free sandbox with native SDK available.
Hi Bart,Thanks for contacting Syncfusion Forums.QUERY: Fill grid after submit without refreshing pageYou have mentioned that you are filling grid after form submit. But you have assigned data source to grid with "DataSource" property. Also you have button "show data". But we can't get what you are doing in button click.Please share us below details so that we could help you to resolve your issue,1) Please explain us your requirement with more clarity( whether you need to render grid in form submit or bind data to it in form submit.2) Please share us your complete grid rendering code zipped (if possible)3) Screenshot of error (if any)4) version detailsIf you have further queries, please get back to us.Regards,Padmavathy Kamalanathan
Index.cshtml
<form>
OrderID: <br> <input type="text" name="OrderID" />
<br>
CustomerName: <br> <input type="text" name="CustomerName" />
<br>
<button type="button" id="button">Submit</button>
</form>
@(Html.EJ().Grid<object>("Grid")
.AllowPaging().PageSettings(page => page.PageSize(12))
.EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing(); })
.Columns(col =>
{
col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).Add();
col.Field("EmployeeID").HeaderText("Employee ID").Add();
col.Field("CustomerID").HeaderText("Customer ID").Add();
col.Field("ShipCity").HeaderText("Ship City").EditType(EditingType.DropdownEdit).Add();
})
)
<script>
document.getElementById('button').onclick = function() {
var data = @Html.Raw(Json.Encode(ViewData["datasource"])); //It helps to get the data from server side
$("#Grid").ejGrid("dataSource", data); //Set data to the datasource property of grid.
}
</script> |
HomeController.cs
public ActionResult Index()
{
if (order.Count() == 0)
BindDataSource();
ViewBag.datasource = order;
ViewData["datasource"] = order;
return View();
}
public void BindDataSource()
{
if (order.Count() == 0)
{
int code = 10000;
for (int i = 1; i < 10; i++)
{
order.Add(new OrderDetails(code + 1, "ALFKI", i + 0, 2.3 * i, new string[] { "Berlin" }, new DateTime(2019, 12, 12, 23, 40, 20)));
order.Add(new OrderDetails(code + 2, "ANATR", i + 2, 3.3 * i, new string[] { "Madrid" }, new DateTime(2019, 12, 11, 23, 50, 20)));
order.Add(new OrderDetails(code + 3, "ANTON", i + 1, 4.3 * i, new string[] { "Cholchester" }, new DateTime(2019, 12, 10, 23, 30, 50)));
order.Add(new OrderDetails(code + 4, "BLONP", i + 3, 5.3 * i, new string[] { "Marseille" }, new DateTime(2019, 12, 13, 23, 50, 50)));
order.Add(new OrderDetails(code + 5, "BOLID", i + 4, 6.3 * i, new string[] { "Tsawassen" }, new DateTime(2019, 12, 14, 23, 55, 55)));
code += 5;
}
}
} |