locked
WebGrid expand/collapse RRS feed

  • Question

  • User1901201124 posted

    Hi all,

    I've followed this to great a expandable and collapsible webgrid.

    http://www.dotnetawesome.com/2014/07/nested-webgrid-with-expand-collapse-in-aspnet-mvc4.html

    Everything seems to be working great. With the example when I go to sort my main table header. When ever I click them the grid either gets blanked out or the hidden table gets shown. Would someone happen to know why this is the case or have implemented this before?

    The only difference i could see that may affect the grid is i am using the

    ajaxUpdateContainerId: "gridT"
    

    Thanks!

    Tuesday, March 5, 2019 6:34 PM

Answers

  • User1901201124 posted

    Figured it out. I had to use

    grid.Column(columnName: "BookId", header: "Book Name", format: (item) => item.Book.Name),
    
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, March 5, 2019 8:59 PM

All replies

  • User1901201124 posted

    Updated: I figured out the issue. I was trying to sort on a Navigation Property and Webgrid was throwing an error. I'm not sure how to resolve this.

    My Model includes the Navigation to the One to Many join table, let's call it "Book"

     model.MyModel = db.MyModels
                .Include(x => x.Book)
    ....etc.

    In my grid i have column:

     grid.Column("Book.Name", "Status", style: ""),

    It renders the Book name properly on the webgrid when i am displaying it. but when i try to sort on the Book Name it throws an error. 

    any ideas?

    Tuesday, March 5, 2019 8:49 PM
  • User1901201124 posted

    Figured it out. I had to use

    grid.Column(columnName: "BookId", header: "Book Name", format: (item) => item.Book.Name),
    
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, March 5, 2019 8:59 PM