ビューに Telerik asp.net グリッドがあります。このグリッドに接続されているモデルには、"State" という名前のフィールドがあります。このフィールドは、各行の状態を保持します。この状態に基づいて、ユーザーは一部の行を編集でき、残りは編集できません。たとえば、行の状態が 0 の場合、ユーザーはそれを編集できます。それ以外の場合は、その行の編集ボタンとその他のコマンドを無効にする必要があります。
だから私の質問は: モデルのフィールドに基づいて行の一部を無効にする方法はありますか?
単純化されたグリッドは次のとおりです。
@{Html.Telerik().Grid<StationEvaluation>().Name("ManagementGrid").DataKeys(dataKeys => dataKeys.Add(o => o.StationEvaluationID)).Groupable().Filterable().Pageable().Sortable().DataBinding(dataBinding => dataBinding.Ajax()
.Delete("DeleteFromGrid", "StationEvaluation")
).Columns(columns =>
{
columns.Command(commands =>
{
commands.Delete().ButtonType(GridButtonType.Image);
commands.Custom("Edit").Action("Edit", "StationEvaluation").ButtonType(GridButtonType.Image).Text("Edit");
}).Title("Manage").Width(50);
columns.Bound(o => o.FromDate);
columns.Bound(o => o.ToDate);
columns.Bound(o => o.DateShow);
columns.Bound(o => o.State).ClientTemplate("<#= StateDsc #>");
columns.Command(commands =>
{
commands.Custom("NextState").Action("NextState", "StationEvaluation").ButtonType(GridButtonType.Text).Text("Next state").Ajax(true);
commands.Custom("PreviousState").Action("PreviousState", "StationEvaluation").ButtonType(GridButtonType.Text).Text("Previous state").Ajax(true);
}).Title("Change state").Width(50);
}).Render();
}