Kendo Grid自定义弹出编辑器模板

时间:2017-06-23 14:38:38

标签: javascript kendo-ui telerik kendo-grid kendo-asp.net-mvc

我有一个Kendo Grid,它链接到自定义弹出编辑器模板。我没有使用Kendo提供的默认添加按钮,因为我需要有几个不同的按钮,它们将一个额外的参数传递给我的on_edit函数,该函数绑定到edit事件。第一次单击添加按钮时一切正常,但是一旦在编辑器窗口中单击了取消按钮,按下任何添加按钮都会在网格中显示一个空行(就好像要由编辑器填充) ,但弹出编辑器窗口本身不会出现。当我简单地从方程中删除模板时,代码都能正常工作,这让我觉得问题不在于我的自定义添加按钮,而在于编辑器模板。

网格声明

HandlerThread

注意:

更换

import matplotlib.pyplot as plt 
l = df.apply(lambda x: ( [x.Value for i in range(x.Start,x.End)] ),axis=1).sum()
plt.plot(l)
plt.show()

@(Html.Kendo().Grid<ScheduleProcess.Process>
()
.Name("grid")
.Columns(columns =>
{
    columns.Bound(c => c.TriggerName);
    columns.Bound(c => c.Description);
    columns.Bound(c => c.Category);
    columns.Bound(c => c.Enabled).ClientTemplate("<input type='checkbox' ${ Enabled == true ? checked='checked' : '' } disabled />").Width(75);
    columns.ForeignKey(c => c.TriggerType, EnumHelper.GetSelectList(typeof(ScheduleProcess.TriggerTypes)).ToList(), "Value", "Text");
    columns.Bound(c => c.LastRun).Format("{0:MM/dd/yy hh:mm:ss tt}");
    columns.Bound(c => c.LastUnSuccessfulRun).Format("{0:MM/dd/yy hh:mm:ss tt}");
    columns.Bound(c => c.EventId);
    columns.Command(c => c.Edit().UpdateText("Save"));
    columns.Command(c => c.Destroy());
    //Hidden Columns
    columns.ForeignKey(c => c.ProcessThreadType, EnumHelper.GetSelectList(typeof(ScheduleProcess.ThreadType)).ToList(), "Value", "Text").Hidden(true);
    columns.Bound(c => c.RunInterval).Hidden(true);
})
.HtmlAttributes(new { style = "height: 750px;" })
.Resizable(resize => resize.Columns(true))
.Scrollable(scrollable => scrollable.Virtual(true))
.Sortable()
.Selectable()
.Editable(edit => edit.Mode(GridEditMode.PopUp).TemplateName("ProcessesEditor"))
.ToolBar(toolbar =>
{
toolbar.Template(
    @<text>
        @(Html.Kendo().Button()
            .Content("Add One Time Trigger")
            .Name("OneTimeTriggerAdd")
            .Events(e => e.Click("AddOneTimeTrigger"))
        )
        &nbsp;
        @(Html.Kendo().Button()
            .Content("Add Interval Trigger")
            .Name("IntervalTriggerAdd")
            .Events(e => e.Click("AddIntervalTrigger"))
        )
        &nbsp;
        @(Html.Kendo().Button()
            .Content("Add Daily Trigger")
            .Name("DailyTriggerAdd")
            .Events(e => e.Click("AddDailyTrigger"))
        )
        &nbsp;
        @(Html.Kendo().Button()
            .Content("Add Weekly Trigger")
            .Name("WeeklyTriggerAdd")
            .Events(e => e.Click("AddWeeklyTrigger"))
        )
        &nbsp;
        @(Html.Kendo().Button()
            .Content("Add Monthly Trigger")
            .Name("MonthlyTriggerAdd")
            .Events(e => e.Click("AddMonthlyTrigger"))
        )
        <br /><br />
        &nbsp;Category:&nbsp;
        @(Html.Kendo().MultiSelect()
                    .Name("CategoryMS")
                    .BindTo((System.Collections.IEnumerable)ViewData["Categories"])
                    .DataTextField("Category")
                    .DataValueField("Category")
                    .Events(e => e.Change("Refresh"))
                    .AutoClose(false)

        )
        &nbsp;
        @(Html.Kendo().Button()
                    .Name("Refresh")
                    .Events(e => e.Click("Refresh"))
                    .Content("Search")
        )
        &nbsp;
        <a class="k-button k-button-icontext k-grid-excel" href="#"><span class="k-icon k-i-excel"></span>Export</a>

    </text>);
})
.Excel(excel => excel
    .FileName("Process_Export.xlsx")
)
.DataSource(dataSource => dataSource
    .Ajax()
    .Events(e => e.Error("onError").RequestEnd("update_grid"))
    .Model(model => {
        model.Id(a => a.TriggerId);
        model.Field(a => a.TriggerId).DefaultValue(0);
        model.Field(a => a.Category);
        model.Field(a => a.DayOfWeek);
        model.Field(a => a.Description);
        model.Field(a => a.DisableAfterFailure);
        model.Field(a => a.Enabled);
        model.Field(a => a.EstimatedProcessRunTime);
        model.Field(a => a.EventId);
        model.Field(a => a.LastRun).DefaultValue(DateTime.MinValue);
        model.Field(a => a.LastUnSuccessfulRun).DefaultValue(DateTime.MinValue);
        model.Field(a => a.MethodParameters);
        model.Field(a => a.ProcessParameters);
        model.Field(a => a.ProcessThreadType);
        model.Field(a => a.Retries);
        model.Field(a => a.RunEvery);
        model.Field(a => a.RunEveryDays);
        model.Field(a => a.RunEveryWeeks);
        model.Field(a => a.RunInterval);
        model.Field(a => a.RunOnDay);
        model.Field(a => a.RunOnDayOf);
        model.Field(a => a.RunOnlyOnWeekdays);
        model.Field(a => a.RunOnWeek);
        model.Field(a => a.RunProcess);
        model.Field(a => a.SelectedEndpointName);
        model.Field(a => a.SelectedMethodName);
        model.Field(a => a.ServiceAddress);
        model.Field(a => a.StartDate);
        model.Field(a => a.StartTime);
        model.Field(a => a.TriggerName);
        model.Field(a => a.TriggerType);
        model.Field(a => a.WaitTimeTillRetry);
        model.Field(a => a.WeekType);
    })
    .Create(update => update.Action("Process_Create", "Grid"))
    .Update(update => update.Action("Process_Update", "Grid"))
    .Destroy(update => update.Action("Process_Destroy", "Grid"))
    .Read(read => read.Action("Process_Read", "Grid"))
    .PageSize(500)
)
)

恢复所有预期功能并完全解决问题。

添加按钮&#39; Javascript函数

.Editable(edit => edit.Mode(GridEditMode.PopUp).TemplateName("ProcessesEditor"))

编辑模板

.Editable(edit => edit.Mode(GridEditMode.PopUp))

我搜索过StackOverflow和Telerik论坛,但我发现的唯一看似相关的帖子是this one,这是尝试使用自定义弹出窗口,而不仅仅是使用编辑器模板。

1 个答案:

答案 0 :(得分:0)

因此,在进一步研究之后,我将脚本包声明留在编辑器模板的顶部,并在模板中重新声明了Kendo javascript函数,这就是导致问题的原因。

删除

<head>
    @Scripts.Render("~/bundles/kendo")
</head>

从编辑器模板文件中修复了意外行为。