0
我的網格具有添加行的功能。我做到了以下幾點:this documentationSyncfusion MVC Grid:在向網格中添加一行時,如何在具有硬編碼值的特定單元格中呈現下拉列表
如何在特定的單元格中創建具有硬編碼值的下拉菜單?
謝謝!
我的網格具有添加行的功能。我做到了以下幾點:this documentationSyncfusion MVC Grid:在向網格中添加一行時,如何在具有硬編碼值的特定單元格中呈現下拉列表
如何在特定的單元格中創建具有硬編碼值的下拉菜單?
謝謝!
我們可以使用ejGrid控件的actionCompelete事件來實現您的需求,並將硬編碼值綁定到該下拉列表。
例如,我們已經爲Grid中的ShipCountry列渲染了ejDropDownList。
請參考下面的代碼示例。
@(Html.EJ().Grid<object>("FlatGrid")
.Datasource((IEnumerable<object>)ViewBag.datasource)
---------
.ClientSideEvents(clienevent => clienevent.ActionComplete("complete"))
.Columns(col =>
{
-----
col.Field("ShipCountry").HeaderText("Ship Country").TextAlign(TextAlign.Right).Width(75).Add();
}))
var data = [
{ id: "1", text: "FRANCE" },
{ id: "2", text: "GERMANY" },
{ id: "3", text: "BRAZIL" },
{ id: "4", text: "BELGIUM" },
{ id: "5", text: "MEXICO" }
];
function complete(args) {
if (args.requestType == "add") {
$("#" + this._id + "ShipCountry").ejDropDownList({
dataSource: data,
field: { text: "text", value: "text" },
width: "100%"
});
}
}
注意:要綁定在ejDropDownList的數據源,我們需要傳遞的文本和值對。
我們準備了一個樣本,它可以從下面的位置下載。