Html.Grid 中的复选框值

发布于 2024-12-02 03:43:13 字数 1154 浏览 2 评论 0原文

我有一个带有发票列表的模型。我正在网格中显示此发票列表。我希望在网格中有一列复选框,以便我可以执行一些附加逻辑。当我发帖时,我将如何读取这些复选框的值?基本上我需要的是在列表中的每个项目的列中都有一个 Html.CheckBoxFor 。我认为这是不可能的,但有没有办法拥有类似的东西?

这是我的网格:

<% Html.Grid(Model.Invoices)     
       .Attributes(@id => "tblInvoiceSearchResults", @class => "tablesorter", style => "width:100%")
       .Empty("No invoice exist with that criteria")
       .Columns(
        col =>
            {
              col.For(c => c.InvoiceNumber).Named("Invoice Number");
              col.For(c => c.InvoicePurchaseOrderNumber).Named("PurchaseOrder");
              col.For(c => c.InvoiceStatus).Named("Invoice Status");
              col.For(c => c.OpenAmount.ToMoneyDisplay()).Visible((bool)ViewData["canSeePricing"])
                    .Named("Open Amt").Attributes(align=>"right");
              col.For(c => c.OriginalAmount.ToMoneyDisplay()).Visible((bool)ViewData["canSeePricing"])
                    .Named("Original Amt")
                    .Attributes(align => "right"); 
              col.For(c => c.InvoiceDate).Named("Invoice Date");
        }).Render();
 %>

I have a model with a List of invoices. I am displaying this list of invoices in a grid. I would like to have a column of check boxes in the grid so I can perform some additional logic. How would I go about reading the values of these check boxes when I post? Basically what I need is to have a Html.CheckBoxFor in a column for each of the items in the list. I don't think that's possible but is there a way to have something similar?

Here's my grid:

<% Html.Grid(Model.Invoices)     
       .Attributes(@id => "tblInvoiceSearchResults", @class => "tablesorter", style => "width:100%")
       .Empty("No invoice exist with that criteria")
       .Columns(
        col =>
            {
              col.For(c => c.InvoiceNumber).Named("Invoice Number");
              col.For(c => c.InvoicePurchaseOrderNumber).Named("PurchaseOrder");
              col.For(c => c.InvoiceStatus).Named("Invoice Status");
              col.For(c => c.OpenAmount.ToMoneyDisplay()).Visible((bool)ViewData["canSeePricing"])
                    .Named("Open Amt").Attributes(align=>"right");
              col.For(c => c.OriginalAmount.ToMoneyDisplay()).Visible((bool)ViewData["canSeePricing"])
                    .Named("Original Amt")
                    .Attributes(align => "right"); 
              col.For(c => c.InvoiceDate).Named("Invoice Date");
        }).Render();
 %>

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

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

发布评论

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

评论(1

祁梦 2024-12-09 03:43:13

经过审查,我猜测您正在使用 mvccontrib-grid?如果是这样,请查看 DD 的答案:带有复选框的 Mvc Contrib 网格

After review, I'm taking a guess that you are using the mvccontrib-grid? If so take a look at this answer from DD: Mvc Contrib grid with checkbox

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