|
@(Html.EJS().Grid("Grid").DataSource((IEnumerable<object>)ViewBag.dataSource).Columns(col =>
{
...
}).EditSettings(e => e.AllowAdding(true).AllowEditing(true).AllowDeleting(true)).Render()) |
Hi Venkatesh,
Actually I'm developing a main page, where there were fields that when I click the add button, should generate a new row in a grid.
This grid is in a partial view, using a model that is updated via ajax.
The problem is that when I add some line the partial view does not reload the grid.
|
[Index.cshtml]
...
<div id="main">
@Html.EJS().Button("primarybtn").Content("Primary").IsPrimary(true).Render()
</div>
<script type="text/javascript">
document.getElementById("primarybtn").addEventListener("click", function () {
//the values entered in the textboxes are assigned to details variable which will be stringified and passed to server.
var details = { OrderID: document.getElementById("ordcol").value, CustomerID: document.getElementById("custcol").value, ... }
var ajax = new ej.base.Ajax("/GridJ2/UrlInsert", 'POST', true); //Post to update the values in partial view Grid
ajax.send(JSON.stringify(details)).then((value) => {
var grid = document.getElementById('GridJ2').ej2_instances[0]; //GridJ2 is the Grid id
grid.refresh(); //refresh the Grid in partial view
});
});
</script>
@{
Html.RenderPartial("_GridFeaturesJ2");
} |