Here's what I've done so far:
I have the grid showing on my page and editable. I am able to send the values from the grid to the server with the form post (using a method similar to the one shown here: http://www.telerik.com/support/code-library/submit-form-containing-grid-along-with-other-input-elements)
I have looked at the custom editor examples here (http://demos.telerik.com/kendo-ui/web/grid/editing-custom.html) and here (http://docs.telerik.com/kendo-ui/getting-started/using-kendo-with/aspnet-mvc/helpers/grid/editor-templates) but this method involves creating a partial view for each dropdown. I would prefer not to have to copy/paste/edit this code every time I need a new dropdown. I think there should be a way to create a re-usable partial view that can perform this function. Along these lines, I have created a small view model and partial view like what is mentioned here (https://stackoverflow.com/questions/11498215/asp-net-mvc-built-in-support-for-dropdownlist-editor-template).
Current status:
The dropdown appears in my grid as expected, and I can select a value. I don't know how to get the text and value of the selected item so I can include them in the ClientTemplate, however.
@(Html.Kendo().Grid<AccountManagement.Business.ViewModels.Areas.DM.RehireDocumentSettingViewModel>()
.Name(
"DocumentSettings"
)
.Columns(columns => {
/*
columns.Bound(ds => ds.FormID)
.ClientTemplate("#= FormID #" +
"<input type='hidden' name='DocumentSettings[#= index(data)#].FormID' value='#= FormID #' />"
);
*/
columns.Bound(ds => ds.FormsViewModel)
.ClientTemplate(
"#= 'test' #"
+
"<input type='hidden' name='DocumentSettings[#= index(data)#].FormID' value='#:data.Value #' />"
);
columns.Bound(ds => ds.DocumentDateTypeName)
.ClientTemplate(
"#= DocumentDateTypeName #"
+
"<input type='hidden' name='DocumentSettings[#= index(data)#].DocumentDateTypeName' value='#= DocumentDateTypeName #' />"
);
columns.Bound(ds => ds.RemoveIfOlderThanDays)
.ClientTemplate(
"#= RemoveIfOlderThanDays #"
+
"<input type='hidden' name='DocumentSettings[#= index(data)#].RemoveIfOlderThanDays' value='#= RemoveIfOlderThanDays #' />"
);
columns.Command(command => command.Destroy());
}
)
.ToolBar(toolbar => {
toolbar.Create();
})
.Navigatable()
.Sortable()
.Scrollable()
.Editable(editable => editable.Mode(GridEditMode.InCell))
.DataSource(dataSource => dataSource
.Ajax()
.Batch(
true
)
.ServerOperation(
false
)
.Events(events => events.Error(
"error_handler"
))
.Model(model => model.Id(ds => ds.FormID))
.Read(
"RehireDocumentSetting_Editing_Read"
,
"RehireSetup"
)
)
)
public
class
DropDownViewModel
{
public
string
SelectedID {
get
;
set
; }
public
IEnumerable<SelectListItem> Items {
get
;
set
; }
}
@model AccountManagement.Business.ViewModels.Areas.DM.DropDownViewModel
@(Html.Kendo().DropDownListFor(m => m)
.DataValueField(
"Value"
)
.DataTextField(
"Text"
)
.BindTo(
new
SelectList(Model.Items,
"Value"
,
"Text"
, Model.SelectedID))
.Value(
"SelectedID"
)
)
01.
@(Html.Kendo().Grid<Models.AgentCommissionDetail>()
02.
.Name(
"commissionGrid"
)
03.
.Columns(
04.
col =>
05.
{
06.
// cols..
07.
})
08.
.ClientDetailTemplateId(
"detailTemplate"
)
09.
.DataSource(dataSource => dataSource
10.
.Ajax()
11.
.ServerOperation(
false
)
12.
)
13.
.Events(events => events.DetailInit(
"initDetail"
))
14.
.BindTo(Model.GroupedDetails)
01.
@(Html.Kendo().Grid<Models.AgentCommissionDetail>()
02.
.Name(
"details_#=CustomerNr#"
)
03.
.Columns(col =>
04.
{
05.
// cols
06.
})
07.
.DataSource(dataSource => dataSource
08.
.Ajax()
09.
.ServerOperation(
false
)
10.
.Sort(p => { p.Add(x => x.ArticleGroup); p.Add(x => x.DiscountGroup); p.Add(x => x.ProductGroup); p.Add(x => x.Revenue).Descending(); })
11.
)
12.
.Pageable()
13.
.Sortable()
14.
.ToClientTemplate()
15.
)
1.
function
initDetail(e) {
2.
var
grid = $(
"#details_"
+ e.data.CustomerNr).data(
"kendoGrid"
);
3.
grid.dataSource.data(e.data.Details);
4.
}
@(Html.Kendo().DropDownList()
.Name("NoRisque") // Name of the widget should be the same as the name of the property
.DataValueField("Value") // The value of the dropdown is taken from the EmployeeID property
.DataTextField("Text") // The text of the items is taken from the EmployeeName property
.BindTo((SelectList)ViewBag.NoSource) // A list of all employees which is populated in the controller
)