如何在编辑模式Kendo MVC网格上的外键列上添加过滤器?

时间:2018-09-03 07:37:52

标签: model-view-controller filter kendo-ui kendo-grid

我想在编辑模式下或当我添加Html.DropdownListFor使用clienttemplate dropdownlist未绑定选定值时将过滤器添加到外键列(SolQRCode)。 谁能帮我吗?

@(Html.Kendo().Grid<TESTVM>() .Name("TESTGrid") .EnableCustomBinding(true) .Editable(editable => editable.Mode(GridEditMode.InLine).DisplayDeleteConfirmation(false)) .AutoBind(true) .Columns(columns => { columns.Bound(c => c.ID).Hidden(); columns.Bound(c => c.SolName).Filterable(true); columns.ForeignKey(p => p.SolTypeID(System.Collections.IEnumerable)ViewData["solTypeDef"], "ID", "SolName").Filterable(true); columns.Bound(c => c.Active).HtmlAttributes(new { style = "text-align: center" }).ClientTemplate("#if(Active){#<i class='fa fa-check-square-o'></i>#} else {#<i class='fa fa-square-o'></i>#}#").Width(96).Filterable(false);
columns.ForeignKey(p => p.SolQRCode, (System.Collections.IEnumerable)ViewData["medicines"], "SolQRCode", "Name").Filterable(true);
columns.Bound(c => c.SolQRCode).ClientTemplate( Html.DropDownListFor(c => c.SolQRCode, new SelectList((System.Collections.IEnumerable)ViewData["medicines"], "SolQRCode", "Name"), "--- Select ---", new { @class = "form-control dropdownErp", @id = "inputSelect" }).ToString());
columns.Command(command => command.Edit().Text("<i class='fa fa-edit'></i>").UpdateText("<i class='fa fa-floppy-o'></i>").CancelText("<i class='fa fa-times'></i>")).HtmlAttributes(new { style = "text-align: center" }).Width(100).Title("Değiştir");
columns.Command(command => command.Destroy().Text("<i class='fa fa-trash'></i>")).HtmlAttributes(new { style = "text-align: center" }).Width(100).Title("Sil");
}) .Filterable(ftb => ftb.Mode(GridFilterMode.Row)) .ToolBar(tools => tools.Excel().Text("Excel'e Aktar")) .Pageable(p => p.Refresh(true) .Sortable() .Scrollable(s => s.Height("50vh")) .DataSource(dataSource => dataSource
.Ajax() .Read("TESTGrid_Read", "TESTGrid", new { fullpage = "true" }) .Create("TESTGrid_Create", "TESTGrid") .Update("TESTGrid_Update", "TESTGrid") .Destroy("TESTGrid_Destroy", "TESTGrid") .PageSize(20) .Model(model => { model.Id(b => b.ObjectID); model.Field(c => c.SolutionTypeID); model.Field(c => c.SolutionQRCode); })
.Events(e => e.Error("TESTGrid_error_handler").RequestStart("TESTGrid_onRequestStart").RequestEnd("TESTGrid_onRequestEnd")) ) .Events(e => e.DataBound("onDataBound").Edit("onGridEdit").Cancel("onCancel")) )

0 个答案:

没有答案