After I load a kendo grid, I would like to refresh/reload the grid with new data using a button click.
Controller:
using Kendo.Mvc;
using Kendo.Mvc.Extensions;
using Kendo.Mvc.Infrastructure;
using Kendo.Mvc.UI;
public ActionResult FollowUpGrid_Read([DataSourceRequest]DataSourceRequest request, string name, string id)
{
List<vmFollowUpGrid> FUPList = new List<vmFollowUpGrid>();
FUPList = (from u in db.usrUserBldgLists
join e in db.entEntities on u.EntID equals e.EntID
join d in db.entDistricts on e.FANo equals d.DistNo
join ed in db.entDistricts on e.OANo equals ed.DistNo
join b in db.entBuildings on e.OBNo equals b.BuildNo
where u.UserID == "A1036719" && u.FANO == id
select new vmFollowUpGrid { FANo = u.FANO, FAName = d.DistrictName, OANo = u.OANO, District = ed.DistrictName, OBNo = u.OBNo, Building = b.BuildName}).Take(50).ToList();
var FUList = FUPList.ToDataSourceResult(request);
return Json(FUList, JsonRequestBehavior.AllowGet);
}
The cshtml page:
@(Html.Kendo().Grid<MDEFollowUp.Models.vmFollowUpGrid>()
.Name("FollowUpGrid")
.Columns(columns =>
{
columns.Bound(p => p.FANo);
columns.Bound(p => p.FAName);
columns.Bound(p => p.OANo);
columns.Bound(p => p.District);
columns.Bound(p => p.OBNo);
columns.Bound(p => p.Building);
})
.Pageable(pageable => pageable
.Refresh(true)
.PageSizes(true)
.ButtonCount(5))
.Sortable()
.Scrollable()
.Filterable()
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Read(read => read.Action("FollowUpGrid_Read", "FollowUp").Data("additionalAgencyInfo")))
)
Then a button click event to refresh the grid with new data but this doesn't seem to recognize the grid assignment.
$("#btnclick").click(function () {
var grid = $("#FollowUpGrid").data("tGrid");
var params = {
name: "Agency",
id: "63190"
};
var dataSource = new kendo.data.DataSource({ data: params });
//grid.rebind(params);
grid.setDataSource(dataSource);
})
How should I assign the grid in the button to accomplish this?