I have a Telerik MVC Grid using ajax to get data and I want to control when it will be loaded.
Here is the code in my view:
@(Html.Telerik().Grid<ViewModels.Reports.UserActionLoggingDetailViewModel>()
.Name("UserActionLoggingFollowedGrid")
.DataBinding(dataBinding => dataBinding.Ajax().Select("SelectUserActionLogging", "Report", new { userTeamId = Model.UserTeamId, startDate = Model.StartDate, endDate = Model.EndDate }).OperationMode(GridOperationMode.Client))
.Columns(columns =>
{
columns.Bound(x => x.FullName).Hidden();
columns.Bound(x => x.ActionName);
columns.Bound(x => x.ActionCount);
})
.Pageable(page => page.PageSize(20))
.Sortable()
.Groupable(grouping => grouping.Groups(groups => groups.Add(c => c.FullName)).Visible(false))
.Filterable()
.Localizable("fr-FR")
.HtmlAttributes(new { @class = "grid-style static-grid-style" })
.ClientEvents(e => e.OnError("Grid_onServerError").OnDataBinding("Grid_onDataBinding").OnDataBound("Grid_onDataBound"))
)
By default, this code works correctly. When the page is loaded, the grid send automatically a post request to the server for the specified action and load itself with the returned datas.
What I want is the same grid with the same behavior but without loading data when the page is loaded; I want the grid to be loaded when the user click a button or any other actions.
I found some interesting posts indicating how to manually refresh the grid but no one specified how to prevent the initial bind of the grid.