Telerik 模态窗口中可以有网格吗?

发布于 2024-12-27 03:39:38 字数 2285 浏览 1 评论 0 原文

我正在使用 ASP.NET MVC 架构。单击按钮有一个 telerik 窗口,效果很好。代码如下 -

    <% Html.Telerik().Window()
           .Name("Search")
           .Visible(false)
           .Title("Select Users")
           .Content(() => {%>                                           
    <% using (Html.BeginForm("GetUsers", "Administration", FormMethod.Post, 
        new{id ="users-form"}))
    {%>

    <p class="note">Mention the Users name to display information</p>                                                 
    <label for="username">Name:</label>                                                        
    <%= Html.TextBox("username") %>                           
    <div class="form-actions">
    <button type="button" class="bUsername">Search</button>
    </div>  
    <% } %>                                           
    <%})
    .Width(400)                                            
    .Modal(true)                                            
    .Render();%>

但是当我尝试在 telerik 窗口的内容中添加 telerik 网格时,它给了我错误。代码如下

    <%= Html.Telerik().Grid(Model)
    .Name("Grid")
    .Columns(columns =>
    {
        columns.Bound(o => o.OrderID).Width(100);
        columns.Bound(o => o.ContactName).Width(200);
        columns.Bound(o => o.ShipAddress);
        columns.Bound(o => o.OrderDate).Format("{0:MM/dd/yyyy}").Width(120);
    })
    .DataBinding(dataBinding => 
    {
        dataBinding.Server().Select("FirstLook", "Grid", new { ajax =
            ViewData["ajax"] });
        dataBinding.Ajax().Select("_FirstLook",
            "Grid").Enabled((bool)ViewData["ajax"]);
    })
    .Scrollable(scrolling => scrolling.Enabled((bool)ViewData["scrolling"]))
    .Sortable(sorting => sorting.Enabled((bool)ViewData["sorting"]))
    .Pageable(paging => paging.Enabled((bool)ViewData["paging"]))
    .Filterable(filtering => filtering.Enabled((bool)ViewData["filtering"]))
    .Groupable(grouping => grouping.Enabled((bool)ViewData["grouping"]))
    .Footer((bool)ViewData["showFooter"])
     %>

错误:.Content(() => {%> ----Delegate System.Func 不接受 0 个参数。

所以想问一下模态窗口中是否可以有网格,如果是的话如何实现它以及如果我们不能比有什么替代方案吗?

I am using ASP.NET MVC architecture.I have a telerik window on a button click, which works fine.The code is as follows-

    <% Html.Telerik().Window()
           .Name("Search")
           .Visible(false)
           .Title("Select Users")
           .Content(() => {%>                                           
    <% using (Html.BeginForm("GetUsers", "Administration", FormMethod.Post, 
        new{id ="users-form"}))
    {%>

    <p class="note">Mention the Users name to display information</p>                                                 
    <label for="username">Name:</label>                                                        
    <%= Html.TextBox("username") %>                           
    <div class="form-actions">
    <button type="button" class="bUsername">Search</button>
    </div>  
    <% } %>                                           
    <%})
    .Width(400)                                            
    .Modal(true)                                            
    .Render();%>

But when I try to add the telerik grid inside the content of telerik window it gives me error..code follows

    <%= Html.Telerik().Grid(Model)
    .Name("Grid")
    .Columns(columns =>
    {
        columns.Bound(o => o.OrderID).Width(100);
        columns.Bound(o => o.ContactName).Width(200);
        columns.Bound(o => o.ShipAddress);
        columns.Bound(o => o.OrderDate).Format("{0:MM/dd/yyyy}").Width(120);
    })
    .DataBinding(dataBinding => 
    {
        dataBinding.Server().Select("FirstLook", "Grid", new { ajax =
            ViewData["ajax"] });
        dataBinding.Ajax().Select("_FirstLook",
            "Grid").Enabled((bool)ViewData["ajax"]);
    })
    .Scrollable(scrolling => scrolling.Enabled((bool)ViewData["scrolling"]))
    .Sortable(sorting => sorting.Enabled((bool)ViewData["sorting"]))
    .Pageable(paging => paging.Enabled((bool)ViewData["paging"]))
    .Filterable(filtering => filtering.Enabled((bool)ViewData["filtering"]))
    .Groupable(grouping => grouping.Enabled((bool)ViewData["grouping"]))
    .Footer((bool)ViewData["showFooter"])
     %>

Error : .Content(() => {%> ----Delegate System.Func does not take 0 arguments.

So want to ask can we have grid inside modal window, if yes then how to implement it and if we cant than whats the alternative to it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

雨落□心尘 2025-01-03 03:39:38

在窗口中显示网格应该不会有任何问题。以下代码使用 Northwind 数据库中的 Customer 实体,对我来说效果很好:

        <% Html.Telerik().Window()
       .Name("TelerikWindow")
       .Title("Grid in Window")
       .Draggable(true)
       .Modal(true)
       .Content(() =>
       { %>
    <%= Html.Telerik().Grid(Model)
            .Name("TelerikGrid")
            .Columns(columns =>
            {
                columns.Bound(c => c.CustomerID);
                columns.Bound(c => c.CompanyName);
                columns.Bound(c => c.ContactName);
                columns.Bound(c => c.Address);
                columns.Bound(c => c.City);
            })
            .Pageable(pageSettings => pageSettings.Enabled(true).PageSize(10))
    %>
    <%})
       .Render();
    %>

我会仔细检查您的代码,以确保您正确设置窗口的内容,因为这似乎就是问题所在从。

You shouldn't have any issues displaying a Grid in a Window. The following code, which uses the Customer entity from the Northwind database, worked just fine for me:

        <% Html.Telerik().Window()
       .Name("TelerikWindow")
       .Title("Grid in Window")
       .Draggable(true)
       .Modal(true)
       .Content(() =>
       { %>
    <%= Html.Telerik().Grid(Model)
            .Name("TelerikGrid")
            .Columns(columns =>
            {
                columns.Bound(c => c.CustomerID);
                columns.Bound(c => c.CompanyName);
                columns.Bound(c => c.ContactName);
                columns.Bound(c => c.Address);
                columns.Bound(c => c.City);
            })
            .Pageable(pageSettings => pageSettings.Enabled(true).PageSize(10))
    %>
    <%})
       .Render();
    %>

I would double-check your code to ensure that you are setting the content of the Window correctly, as that seems to be where the issue is coming from.

深海夜未眠 2025-01-03 03:39:38

您可以使用委托方法或直接输出在窗口内定义网格:

MVC 2:

<% Html.Telerik().Window()
    ...
    .Content(() =>
    {%>
        <%= Html.Telerik().Grid(***)
            ...
        %>
    <%})
    .Render();
%>

MVC 3 Razor:

@(Html.Telerik().Window()
    ...
    .Content(
        @<text>
            @(Html.Telerik().Grid<***>()
                ...
            )
        </text>
    )
)

另请参阅:

窗口内网格 - 论坛

与 Razor View Engine 一起使用 - 帮助

You can define Grid inside Window by using delegate method or direct output:

MVC 2:

<% Html.Telerik().Window()
    ...
    .Content(() =>
    {%>
        <%= Html.Telerik().Grid(***)
            ...
        %>
    <%})
    .Render();
%>

MVC 3 Razor:

@(Html.Telerik().Window()
    ...
    .Content(
        @<text>
            @(Html.Telerik().Grid<***>()
                ...
            )
        </text>
    )
)

See Also:

Grid inside Window - Forum

Using with the Razor View Engine - Help

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文