自定义kendo网格弹出编辑器的错误包含另一个网格

时间:2014-09-07 09:36:30

标签: jquery kendo-ui asp.net-mvc-5 kendo-grid mvc-editor-templates

我有一个剑道网格,在其弹出式编辑器中有另一个剑道网格(甚至是列表视图)。 我的内部网格使用EditorTemplates作为我的一个模型编辑器。 当我想打开外部网格的弹出窗口时,我得到了SyntaxError:未终止的字符串文字并且无法打开网格的弹出窗口。 这是错误的图像: enter image description here

以下是外部网格的代码:

@(Html.Kendo().Grid<CallCenter.CCAdminWeb.BLL.Operator.OperatorItem>()
    .Name("grdOperatorEditor")
    .Columns(columns =>
    {
        columns.Command(command => command.Edit().UpdateText(TazarvGrid.UpdateText).CancelText(TazarvGrid.CancelText)).Hidden();
        columns.Bound(model => model.OperatorNumber).Width(85);
        columns.Bound(model => model.Name).Width(175);
        columns.Bound(model => model.Role).Width(85);
        columns.Bound(model => model.CreationDate).Width(85);
        columns.Bound(model => model.WorkstationID).Width(95);
        columns.Bound(model => model.Enable).ClientTemplate("<input type='checkbox' disabled='disabled' checked='#= Enable #'")
            .Width(75);
    })
    .Pageable(pager => pager
        .Input(true)
        .Messages(msg => msg
        .Display(TazarvGrid.PagerDisplay)
        .Empty(TazarvGrid.PagerEmpty)
        .First(TazarvGrid.PagerFirst)
        .ItemsPerPage(TazarvGrid.PagerItemsPerPage)
        .Last(TazarvGrid.PagerLast)
        .Next(TazarvGrid.PagerNext)
        .Of(TazarvGrid.PagerOf)
        .Page(TazarvGrid.PagerPage)
        .Previous(TazarvGrid.PagerPrevious)
        .Refresh(TazarvGrid.PagerRefresh))
        .Refresh(true)
        .PageSizes(new[] { 5, 10, 20 })
        .ButtonCount(5)
    )
    .ToolBar(tlb => tlb.Template(@<text>
        <div class="toolbar">
            <a id="btnAdd" class='k-button k-button-icontext k-grid-add' onclick="gridOPAddRow()" title="@TazarvGrid.AddButtonTitle" href='#'>
                <span class="k-icon k-add"></span>
            </a>
            <a id="btnEdit" class='k-button k-button-icontext k-grid-edit' onclick="gridEditRow()" title="@TazarvGrid.EditButtonTitle" href='#'>
                <span class="k-icon k-edit"></span>
            </a>
            <a id="btnDelete" class='k-button k-button-icontext k-grid-delete' onclick="gridDeleteRow()" title="@TazarvGrid.RemoveButtonTitle" href='#'>
                <span class="k-icon k-delete"></span>
            </a>
        </div>
    </text>
        ))
        .Resizable(res => res.Columns(true))
        .AutoBind(true)
        .Sortable()
        .Filterable(filter => filter
            .Messages(msg => msg
            .And(TazarvGrid.FilterAnd)
            .Clear(TazarvGrid.FilterClear)
            .Filter(TazarvGrid.FilterFilter)
            .Info(TazarvGrid.FilterInfo)
            .IsFalse(TazarvGrid.FilterIsFalse)
            .IsTrue(TazarvGrid.FilterIsTrue)
            .Or(TazarvGrid.FilterOr)
            .SelectValue(TazarvGrid.FilterSelectValue))
            .Operators(op => op
                .ForNumber(num => num
                    .Clear()
                    .IsEqualTo(TazarvGrid.FilterOpNumIsEqualTo)
                    .IsGreaterThan(TazarvGrid.FilterOpNumIsGreaterThan)
                    .IsGreaterThanOrEqualTo(TazarvGrid.FilterOpNumIsGreaterThanOrEqual)
                    .IsLessThan(TazarvGrid.FilterOpNumIsLessThan)
                    .IsLessThanOrEqualTo(TazarvGrid.FilterOpNumIsLessThanOrEqual)
                    .IsNotEqualTo(TazarvGrid.FilterOpNumIsNotEqualTo)
                )
                .ForString(str => str
                    .Clear()
                    .Contains(TazarvGrid.FilteOpStrContain)
                    .DoesNotContain(TazarvGrid.FilteOpStrDoesNotContain)
                    .EndsWith(TazarvGrid.FilteOpStrEndWith)
                    .IsEqualTo(TazarvGrid.FilteOpStrIsEqualTo)
                    .IsNotEqualTo(TazarvGrid.FilteOpStrIsNotEqualTo)
                    .StartsWith(TazarvGrid.FilteOpStrStartWith)
                )
                .ForDate(date => date
                    .IsEqualTo(TazarvGrid.FilterOpDateIsEqualTo)
                    .IsGreaterThan(TazarvGrid.FilterOpDateIsGreaterThan)
                    .IsGreaterThanOrEqualTo(TazarvGrid.FilterOpDateIsGreaterThanOrEqual)
                    .IsLessThan(TazarvGrid.FilterOpDateIsLessThan)
                    .IsLessThanOrEqualTo(TazarvGrid.FilterOpDateIsLessThanOrEqual)
                    .IsNotEqualTo(TazarvGrid.FilterOpDateIsNotEqualTo)
                )
                .ForEnums(enm => enm
                    .IsEqualTo(TazarvGrid.FilterOpEnumIsEqualTo)
                    .IsNotEqualTo(TazarvGrid.FilterOpEnumIsNotEqualTo)
                )
            ))
            .Events(e => e.Edit("gridOPOnEdit"))
                .Editable(ed => ed.Mode(GridEditMode.PopUp).TemplateName("Operator").DisplayDeleteConfirmation(false)
                .Window(editWin => editWin.Title("کارشناس").Width(600)))
            .Selectable()
            .Scrollable(scr => scr.Height(385))
            .DataSource(dataSource => dataSource
                .Ajax()
                .ServerOperation(false)
                .Model(model =>
                    {
                        model.Id(id => id.OperatorNumber);
                        model.Field(field => field.CreationDate).DefaultValue(CallCenter.CCAdminWeb.DAL.DALHelper.DALCalender.MiladiToShamsi(DateTime.Now));
                    })

                .Read(read => read.Action("OperatorList_Read", "OperatorEditor"))
                .Update(update => update.Action("OperatorItem_Update", "OperatorEditor"))
                .Destroy(destroy => destroy.Action(/* action */"OperatorItem_Delete", /* controller */ "OperatorEditor"))
                .Create(create => create.Action("OperatorItem_Create", "OperatorEditor"))
                .Events(e => e.Error("gridErrorHandler"))
            )
)

运营商的编辑器模板代码:

    <script type="text/x-kendo-tmpl" id="OperatorsWorkgroupItem">
    <div class="product-view k-widget">
        <h3 onclick="productView_OnClick(this)">
            <label>
                #=getWorkgroupName(WorkgroupID,function(value){ return value; })#
            </label>
            <div class="edit-buttons">
                <a class="k-button k-button-icontext k-edit-button" href="\\#"><span class="k-icon k-edit"></span></a>
                <a class="k-button k-button-icontext k-delete-button" href="\\#"><span class="k-icon k-delete"></span></a>
            </div>
        </h3>
        <dl>
            <dt>زمان تکمیل پرونده:</dt>
            <dd>#:MakeBusyLeftTime#</dd>
            <dt>اولویت:</dt>
            <dd>#:Priority#</dd>
        </dl>
    </div>
</script>

@(Html.Kendo().ListView<OperatorWorkgroupItem>()
                .Name("livOPEditorsWorkgroup")
                .TagName("div")
                .ClientTemplateId("OperatorsWorkgroupItem")
                .Events(ev => ev.Edit("livOPEditorsWorkgroupOnEdit"))
                .DataSource(dataSource => dataSource
                    .Model(model => model.Id(id => id.WorkgroupID))
                    .PageSize(6)
                    .Update(read => read.Action("OperatorsWorkgroupList_Update", "OperatorEditor").Data("getOperatorNumber"))
                    .Destroy(read => read.Action("OperatorsWorkgroupList_Delete", "OperatorEditor").Data("getOperatorNumber"))
                    .Create(read => read.Action("OperatorsWorkgroupList_Create", "OperatorEditor").Data("getOperatorNumber"))
                    .Read(read => read.Action("OperatorsWorkgroupList_Read", "OperatorEditor").Data("getOperatorNumber"))
                    .Events(ev => ev.Error("livOPEditorsWorkgroupOnDSError"))
                )
                .Editable()

和OperatorsWorkgroupItem Editor模板代码:

    @model CallCenter.CCAdminWeb.BLL.Operator.OperatorWorkgroupItem
<div class="product-view product-edit">
    <h3>
        <div class="edit-buttons">
            <a class="k-button k-button-icontext k-update-button" href="\\#"><span class="k-icon k-update"></span></a>
            <a class="k-button k-button-icontext k-cancel-button" href="\\#"><span class="k-icon k-cancel"></span></a>
        </div>
    </h3>
    <dl>
        <dt>@Html.LabelFor(p => p.WorkgroupID)</dt>
        <dd>
            @*@(Html.TextBoxFor(p => p.WorkgroupID))*@
            @(Html.Kendo().DropDownListFor(p => p.WorkgroupID)
                .HtmlAttributes(new { @class = "OPWGEditorWorkGroup" })
                .BindTo((CallCenter.CCAdminWeb.BLL.WorkGroup.WorkGroupItemList)ViewData["WorkgroupList"])
                .DataTextField("Name")
                .DataValueField("ID")
            )
            <!-- ProductName validation message placeholder -->
            <span data-for="WorkgroupID" class="k-invalid-msg"></span>
        </dd>
        <dt>@Html.LabelFor(p => p.MakeBusyLeftTime)</dt>
        <dd>
            @(Html.Kendo().NumericTextBoxFor(p => p.MakeBusyLeftTime).Min(0))
            <!-- UnitPrice validation message placeholder -->
            <span data-for="MakeBusyLeftTime" class="k-invalid-msg"></span>
        </dd>
        <dt>@Html.LabelFor(p => p.Priority)</dt>
        <dd>
            @(Html.Kendo().NumericTextBoxFor(p => p.Priority).Min(0))
            <!-- UnitsInStock validation message placeholder -->
            <span data-for="Priority" class="k-invalid-msg"></span>
        </dd>
    </dl>
</div>

当我在单独的视图中复制listview时,它工作正常。但是当我将listview添加到grid的自定义弹出编辑器时,就会发生这种情况。

1 个答案:

答案 0 :(得分:0)

将.ToClientTemplate()添加到嵌套在弹出编辑器中的网格