Hi Georgi,
The "public JsonResult OnPostRead" is not firing at my end although on the sample, the "public JsonResult OnPostRead" is firing. The difference is that I'm using "public async Task OnGetAsync()" with a couple of await in getting token and response from api, whereas on the sample its just using "public void OnGet()" that creates a data list on the fly w/o waiting for data response.
.cs (No issue on getting data from api and set it to UsersList)
The issue is the "public JsonResult OnPostRead" is firing
public static IList<
UserList
> users;
public async Task OnGetAsync()
{
users = new List<
UserList
>();
var user = await _userManager.GetUserAsync(User);
if (user == null)
{
throw new ApplicationException($"Unable to load user with ID '{_userManager.GetUserId(User)}'.");
}
string Token = await _userManager.GetAuthenticationTokenAsync(user);
userData = await _restCall.GetUsers(Token, "api/userList").ToList();
userData.ForEach(obj => users.Add(new UserList
{
Id = obj.Id,
firstName = obj.firstName,
middleName = obj.middleName,
lastName = obj.lastName,
email = obj.email,
}));
}
//not firing
public JsonResult OnPostRead([DataSourceRequest] DataSourceRequest request)
{
return new JsonResult(users.ToDataSourceResult(request));
}
chtml
<
h2
>Kendo UI Grid</
h2
>
@(Html.Kendo().Grid<
UserList
>().Name("grid")
.Groupable()
.Sortable()
.Editable()
.Scrollable()
.ToolBar(x => x.Excel())
.Columns(columns =>
{
columns.Bound(column => column.firstName);
columns.Bound(column => column.middleName);
columns.Bound(column => column.lastName);
columns.Bound(column => column.email);
columns.Command(column =>
{
column.Edit();
});
})
.Excel(excel => excel
.FileName("Export.xlsx")
.Filterable(true)
.ProxyURL("/Users?handler=Save")
)
.DataSource(ds => ds.Ajax()
.Read(r => r.Url("/Users?handler=Read").Data("forgeryToken"))
.Model(m => m.Id(id => id.Id))
.PageSize(10)
)
.Pageable()
)
Anything I miss?
Thanks in advance!
Ryan