kendo-ui - 在 Kendo Grid 中添加下拉菜单

标签 kendo-ui kendo-grid kendo-asp.net-mvc kendo-dropdown

我试图在剑道网格内添加一个下拉菜单,但它显示一个文本框

 @(Html.Kendo().Grid((IEnumerable<Doc.Web.Models.Vendor.DocumentsDetails>)Model.documents_lst)
    .Name("grid").Scrollable()

    .Columns(columns =>
    {

        columns.Bound(o => o.DocumentRevisionID).Visible(false);
        columns.Bound(o => o.Documentnumber).Title("Document #").Width(150);
        columns.Bound(o => o.Revision).Title("Revision").Width(80);
        columns.Bound(o => o.RevisionDate).Format("{0:dd/MM/yyyy}").Title("Rev Date").Width(85);
        columns.Bound(o => o.RevisionStatus).Title("Revision</br> Status").Width(100);
        columns.Bound(s => s.DocNumberPurpose).ClientTemplate((@Html.Kendo().DropDownList()
     .BindTo((System.Collections.IEnumerable)ViewData["Purpose"])
      .Name("DocNumberPurpose")
       .DataTextField("Text")
          .DataValueField("Value")
          .ToClientTemplate()).ToHtmlString());

    })
    .DataSource(dataSource => dataSource
        .Ajax()
        .Model(model => model.Id(o => o.DocumentRevisionID))
        .Model(model=>model.Field(o=>o.DocNumberPurpose).Editable(false))
    )

    .Events(ev=>ev.DataBound("onGridDataBound"))
    .Pageable()
    .Sortable()
    .Filterable()
    .DataSource(dataSource => dataSource
        .Ajax()
        .PageSize(5)
        .Events(events => events.Error("error_handler"))
        .Model(model => model.Id(p => p.DocumentRevisionID))
        .Read(read => read.Action("EditingInline_Read", "DesignCoverSheet").Data("additionalInfo"))

    )

     )

 <script>

         function onGridDataBound(e) {
             $('#grid script').appendTo(document.body);
         }

 </script>  

最佳答案

实际上你非常接近:

columns.Bound(property => property.neatProperty).Width(38).EditorTemplateName("neatPropertyDropDownList").Title("NeatProperty")

然后在一个名为“neatPropertyDropDownList.cshtml”的单独 View 中

@using System.Collections;

@(Html.Kendo().DropDownList()
            .Name("NeatProperty")       
            .DataTextField("Value")
            .DataValueField("Text")
            .BindTo("don't forget to bind!")
 )

关于kendo-ui - 在 Kendo Grid 中添加下拉菜单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22030725/

相关文章:

javascript - 无法更改工具栏上 Kendo 导出到 Excel 按钮的标题

kendo-ui - Kendo Grid,如何在按下输入后禁用列上方搜索输入中的自动完成和过滤图标以及处理请求?

javascript - 如何在剑道网格中手动设置列值

asp.net-mvc-4 - 如何将 kendo ui mvc 网格绑定(bind)到对象列表

asp.net-mvc - 在表单提交上发布 Kendo 网格数据

c# - 在 map 上创建定位点的更好方法

javascript - Kendo UI (ASP.NET/Javascript) - 字符串中的换行符或换行符未显示在工具提示中

kendo-ui - 网格的弹出编辑表单 : how can I know which is the currently selected row

javascript - Kendo 窗口 - 提交时不要关闭窗口

javascript - Kendo-ui 网格 : Can the standard HTML5 input date-time be used as a cell editor?