Hi,
I have a asp.net 6 razor page with a ej2 grid which displays data from a database as below
<ejs-grid id="grid" dataSource="@Model.NewStockRequestViewModel"></ejs-grid>
This displays data correctly. Now on click of a button, I change some data in the database and I want this to reflect in my grid without having to refresh the browser.
I tried the following but it doesn't work
function refreshGrid() {
const ajax = new ej.base.Ajax("/api/StockRequests/GetDataForGrid", "GET", true); // call API
ajax.send();
ajax.onSuccess = function (data) {
alert("Success 2");
console.log(data);
const grid = document.getElementById("grid")["ej2_instances"][0];
grid.dataSource = ej.data.DataUtil.parse.parseJson(data).result;
};
}
I can see success and also the json data returned by the api as below. However the grid is emptied and does not has zero rows.
Thanks
Avinash Tauro