Example:
@using DevExtremeAspNetCoreApp2.Models
<h2>Home</h2>
<button type="Submit" id="btnSave" accesskey="O" class="btn btn-primary" value="Save">Save</button>
@(Html.DevExtreme().DataGrid<Order>()
.ID("widget")
.DataSource(d => d.Mvc().Controller("Orders").LoadAction("Get").Key("OrderID"))
.Columns(columns =>
{
columns.AddFor(m => m.OrderID);
columns.AddFor(m => m.OrderDate);
columns.AddFor(m => m.CustomerName);
columns.AddFor(m => m.ShipCountry);
columns.AddFor(m => m.ShipCity);
})
)
<script>
$("#btnSave").click(function () {
var datagrid = $("#widget").dxDataGrid("getDataSource");
$.ajax( {
type: "POST", //HTTP POST Method
url: "Home/Save", // Controller/View
datatype: "json",
data: {
'SelectedData': JSON.stringify(datagrid.items())
}
});
});
</script>
1 Comments
hi ..
ReplyDelete