BoldSignA modern eSignature application with affordable pricing. Sign up today for unlimited document usage!
<Grid>
@(Html.EJ().Grid<object>("Grid")
//intially we didn't bind the datasource for Grid
.AllowPaging()
.AllowSorting()
.PageSettings(page => { page.PageSize(8); })
. . .
})
.Columns(col =>
{
. . .
})
)
<AJAX>
<script type="text/javascript">
$.ajax({
url: "/api/Orders", // call the wepapi controller
contentType: "application/json; charset=utf-8",
type: "GET",
datatype: "JSON",
success: function (jsonResults) {
var gridObj = $("#Grid").ejGrid("instance");//Grid instance
gridObj.dataSource(jsonResults.Items); // bound the Grid dataSource. here we should bound the array of objects as datasource not a string and this is a recommended way
},
error: function (jsonResults) {
alert("Error");
}
});
</script> |