繁体   English   中英

在剑道网格中下拉

[英]DropDown In Kendo Grid

我需要在剑道网格中添加一个下拉菜单。 我试图通过使用EditorTemplate进行添加,但是代码中有一些不正确的原因,这对我不起作用。下拉列表具有3个值(捐赠,退款,撤消)。 以下是我的剑道网格,我需要在第一列上显示下拉菜单。 请帮忙。

  @(Html.Kendo().Grid<GA.CustomerCare.Web.Synergy.Models.CustomerOrderARInfo>
                    (Model.CustomerOrderARInfoResult)
                    .Name("SearchResultsGridParent")
                    .Columns(columns =>
                    {
                        columns.Bound(e => e.ActionList).Width(100).EditorTemplateName("ActionDropdownEditor");
                        columns.Bound(e => e.TransNumber).Width(85);
                        columns.Bound(e => e.OriginalTransNumber).Width(85);
                        columns.Bound(e => e.DateEntered).Width(115);
                        columns.Bound(e => e.TransDate).Width(85);
                        columns.Bound(e => e.TransType).Width(130);
                        columns.Bound(e => e.Status).Width(100);
                        columns.Bound(e => e.Amount).Width(100);
                        columns.Bound(e => e.AmountApplied).Width(100);
                        columns.Bound(e => e.AvailableFunds).Width(85);
                        columns.Bound(e => e.AdjustmentReason).Width(85);
                        columns.Bound(e => e.CcCheckGiftCard).Width(155);
                        columns.Bound(e => e.PaypalTransID).Width(135);
                        columns.Bound(e => e.Area).Width(85);
                        columns.Bound(e => e.EnteredBy).Width(115);
                        columns.Bound(e => e.Reference).Width(155);
                        columns.Bound(e => e.DateCapture).Width(155);
                        columns.Bound(e => e.AmountCapture).Width(155);

                    })
                    .Sortable(sortable => sortable
                    .AllowUnsort(true)
                    .SortMode(GridSortMode.MultipleColumn)
                    )
                    .Resizable(resize => resize.Columns(true))
                    .ColumnResizeHandleWidth(10)
                    .Scrollable(scrolling => scrolling.Height(190))
                    //.ClientDetailTemplateId("template")
                                                        //.HtmlAttributes(new { style = "height:430px;" })
                    .DataSource(dataSource => dataSource
                    .Ajax()
                    .Read(read => read.Action("GetCustomerOrderAR", "Order", new { CustomerOrderID = Model.CustomerOrderID }))
                    )
                                                        )

以下是我在模型中使用的属性:

  [Display(Name = "ActionList")]
    public string ActionList { get; set; }

以下是我的ActionDropdownEditor:

@model string

   @(Html.Kendo().DropDownList()
            .Name("ActionList")  //Important, must match the column's name
        .Value(Model)
        .SelectedIndex(0)
        .BindTo(new string[] { "Donate", "Refund", "Undo" })) 

我还尝试了通过与DropDown相同的方式来使用Kendo Grid和DropDown,并且效果良好。 请检查您的代码是否缺少某些参考。

column.Bound(p => p.ActionList).ClientTemplate("#= ActionList !=null ? ActionList : '' #").EditorTemplateName("_Sex").Title("ActionList");

我将整个Dropdown放在EditorTemplates文件夹中,以供您检查您的代码:

@using Kendo.Mvc.UI
@(Html.Kendo().DropDownListFor(m => m)
                .Name("ActionList").HtmlAttributes(new { @style = "font-size:12px", @class = "PaxType" })
                  .BindTo(new string[] { "Donate", "Refund", "Undo" }))

您可以通过在ClientTemplate中使用html将DropDownList放置到Kendo网格中。 我使用以下方法实现了类似的目标...

column.Bound(p => p.WFKeyType).Title("Type").ClientTemplate("<select class='form-control'><option value='' disabled='disabled' selected='selected'>Select Key Type</option><option value='String'>String</option><option value='Integer'>Integer</option><option value='DateTime'>DateTime</option><option value='Currency'>Currency</option><option value='Bool'>Bool</option></select>");

它会在Grid列中生成一个DropDownList,其中包含“ String”,“ Integer”,“ DateTime”,“ Currency”和“ Bool”作为选项。 “ form-control”类来自Bootstrap,有助于使列看起来更整洁。 您的项目将需要添加Bootstrap 3,然后才能访问该类。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM