ajaxを使用してデータを取得するTelerikMVCグリッドがあり、いつロードされるかを制御したいと思います。
これが私の見解のコードです:
@(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"))
)
デフォルトでは、このコードは正しく機能します。ページが読み込まれると、グリッドは指定されたアクションのPOSTリクエストをサーバーに自動的に送信し、返されたデータを自分自身に読み込みます。
私が欲しいのは、同じ動作の同じグリッドですが、ページがロードされるときにデータをロードしません。ユーザーがボタンまたはその他のアクションをクリックしたときにグリッドが読み込まれるようにしたい。
グリッドを手動で更新する方法を示す興味深い投稿をいくつか見つけましたが、グリッドの最初のバインドを防ぐ方法を指定した人は誰もいませんでした。