Nick
Nick

Reputation: 1891

CheckBox values in Html.Grid

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();
 %>

Upvotes: 2

Views: 1338

Answers (1)

Jesse
Jesse

Reputation: 8393

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

Upvotes: 1

Related Questions