询问kendo ui,如何使用另一个页面的ajax调用数据?

问题描述 投票:0回答:2

假设我的页面A如下所示:

<div class="buttonsarea">
            @*@Html.ButtonWithPrivilege("button", PrivilegeCode.Create, ControllerHelper.GetCurrentControlerName(), @SharedResource.AddButton, new { @class = "button green", @id = "btnCreateGroup", onclick = "onCreateGroup(event)" })
                <button type="button" class="button red" onclick="closeInnerWindow(this);" >@SharedResource.CancelButton</button>
                <button type="button" class="button yellow" onclick="clearInputForm();">@SharedResource.ClearButton</button>*@
        </div>
    }
</div>
@(Html.Kendo().Grid<Model.Role>()
        .Name("GroupsGrid")
        .ToolBar(toolBar => toolBar.Template(
         @<text>

            <div class="input-group searchButton">
                <input type="text" id="searchKey" class="form-control" autocomplete="off" placeholder="@SharedResource.SearchButton" aria-label="@SharedResource.SearchButton" aria-describedby="basic-addon2">
                <div class="input-group-append">
                    <button id="btnSearch" class="btn btn-outline-primary" type="button">@SharedResource.SearchButton</button>
                </div>
            </div>

        </text>))
        .Columns(columns =>
        {

然后,我使用ajax调用另一页(下面的代码)以将此代码添加到kendo窗口中,但是由于无效模板,我被卡住了,我也无法对此代码使用哈希转义,因为那样我就无法得到结果,我该怎么办才能解决此问题?

    @{
    var roleId = ViewData["GroupId"] as String;
    var columnWidth = 50;
    Layout = null;
}
@using BackEnd.Helpers
@Html.Hidden("GroupId", roleId)

@{Html.Kendo().Grid<Model.Menu>()
                .Name("GridMenus")
                .Columns(columns =>
                {
                    columns.Bound(o => o.TextEng).ClientTemplate("<# if ( ParentId == 0 ) { #>" +
                        "<div class='privilege-lvl-0'><a id='<#= MenuId #>' href='#' title='<#= TextThai #>'><#= TextEng #></a></div>" +
                        "<# } else if( HasChild == 0 && MenuLevel > 0 ) { #>" +
                        "<div class='privilege-lvl-1'><a id='<#= MenuId #>' href='#' title='<#= TextThai #>'><#= TextEng #></a></div>" +
                        "<# } else if( HasChild < 0 && MenuLevel > 1 ) { #>" +
                        "<div class='privilege-lvl-2'><a id='<#= MenuId #>' href='#' title='<#= TextThai #>'><#= TextEng #></a></div>" +
                        "<# } else { #>" +
                        "<div class='privilege-lvl-3'><a id='<#= MenuId #>' href='#' title='<#= TextThai #>'><#= TextEng #></a></div>" +
                        "<# } #>"
                       ).Title(@Privilege.PageName).Width(200);
                    columns.Bound(o => o.MenuId).HeaderTemplate(@<text>
@Privilege.View
                    </text>).ClientTemplate("&nbsp;").Width(columnWidth);
               columns.Bound(o => o.MenuId).HeaderTemplate(@<text>
@Privilege.Create
            </text>).ClientTemplate("&nbsp;").Width(columnWidth);
                columns.Bound(o => o.MenuId).HeaderTemplate(@<text>
@Privilege.Update
                </text>).ClientTemplate("&nbsp;").Width(columnWidth);
                     columns.Bound(o => o.MenuId).HeaderTemplate(@<text>
@Privilege.Delete
                    </text>).ClientTemplate("&nbsp;").Width(columnWidth);
                      })
           .DataSource(dataBinding =>
           {
               dataBinding.Ajax().Read("GetMenuList", "UserPrivilegeManagement").PageSize(22);
           })
           .Events(clientEvents => clientEvents
           .DataBound("GridMenus_onRowDataBound")
           //.OnComplete("GridMenus_onComplete")
           )
           .Scrollable(scrolling => scrolling.Height(336))
           .Pageable(paging => paging.PageSizes(BackEnd.Helpers.GridHandler.PageSize))

以下为错误:

Uncaught Error: Invalid template:'<tr data-uid="#=data.uid#" role='row'><td data-field="TextEng"class="#= data && data.dirty && data.dirtyFields && data.dirtyFields['TextEng'] ? ' k-dirty-cell' : '' #" role='gridcell'>#= data && data.dirty && data.dirtyFields && data.dirtyFields['TextEng'] ? '<span class="k-dirty"></span>' : '' #<//# if ( ParentId == 0 ) { <div class='privilege-lvl-0'><a id='//#= MenuId //#' href='//#' title='//#= TextThai //#>' //#= TextEng //#</a></div> }//</td><td data-field="MenuId"class="#= data && data.dirty && data.dirtyFields && data.dirtyFields['MenuId'] ? ' k-dirty-cell' : '' #" role='gridcell'>#= data && data.dirty && data.dirtyFields && data.dirtyFields['MenuId'] ? '<span class="k-dirty"></span>' : '' # </td><td data-field="MenuId"class="#= data && data.dirty && data.dirtyFields && data.dirtyFields['MenuId'] ? ' k-dirty-cell' : '' #" role='gridcell'>
javascript asp.net-mvc kendo-ui telerik
2个回答
0
投票

您必须使用#转义\\#。示例:


0
投票

[我花了很多小时进行搜索后,得到了新的解决方案,我使用myTemplate调用javascript,然后执行其他操作并返回值:

© www.soinside.com 2019 - 2024. All rights reserved.