5

私は剣道グリッドを次のように設定しています:

@(Html.Kendo().Grid<ParticipatingDentalEE>()
.Name("DentalEE")
.Columns(columns =>
{
    columns.Bound(p => p.State).Title("State").Width(150).EditorTemplateName("State");
    columns.Bound(p => p.Count).Title("Count").Width(150);
    columns.Command(c => { c.Edit(); c.Destroy(); });
})
.DataSource(dataSource => dataSource
    .Ajax()           
    .Model(m => {
        m.Id(p => p.State);
        m.Field(p => p.State).Editable(true);
        m.Field(p => p.Count).Editable(true).DefaultValue("");
    })
    .Create(update => update.Action("EditingInline_Create", "Dental"))
    .Read(read => read.Action("EditingInline_Read", "Dental"))
    .Update(update => update.Action("EditingInline_Update", "Dental"))
    .Destroy(update => update.Action("EditingInline_Destroy", "Dental"))
)
//.Scrollable()
//.Sortable()
.Editable(e => e.Mode(GridEditMode.InLine))

)

「状態」列は、次のようなドロップダウン テンプレートで構成されます。

@(Html.Kendo().DropDownList()
    .Name("States") // Name of the widget should be the same as the name of the property
    .DataValueField("CODE") // The value of the dropdown is taken from the EmployeeID property
    .DataTextField("NAME") // The text of the items is taken from the EmployeeName property
    .BindTo((System.Collections.IEnumerable)ViewData["States"]) // A list of all employees which is populated in the controller
)

アイテムを編集または作成するとドロップダウンが正しく表示されますが、アイテムを保存するとドロップダウンの値がグリッドに残りません。これを行うために設定する必要があるものは他にありますか?

4

3 に答える 3

4

ご自身のコメントでおっしゃっているように、

.Name("States") // Name of the widget should be the same as the name of the property

つまり、列の名前と一致する必要があり、列名は「States」ではなく「State」です。

于 2013-12-18T04:35:51.833 に答える
3

明らかにこれは古いスレッドですが、名前を指定せずに (DropDownList ではなく) DropDownListFor メソッドを使用することで解決されます。Kendo は、編集された値をモデルに適用するために内部的な名前の照合を行っていると思われます。

@model int // ...or whatever type works for your model

@(Html.Kendo().DropDownListFor(i => i)
    .DataValueField("CODE")
    .DataTextField("NAME")
    .BindTo((System.Collections.IEnumerable)ViewData["States"]))
于 2013-10-29T01:40:10.090 に答える
0

これで問題が解決するかどうかはわかりませんが、モデルとビューでUIHintデコレータを設定するまで、グリッドのエディタ テンプレートが正しく機能しませんでした。EditorTemplateName

例えば

public class ParticipatingDentalEE {
   ...

   [UIHint("State")] // this should be the name of your EditorTemplate
   public State State { get; set; }

}

UIHintは「表示」モードでグリッドに使用されEditorTemplateName、「編集」モードでは が使用され、2 つをリンクするには両方が必要であると推測します。

于 2013-08-22T17:02:32.397 に答える