Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
349
WebGrid with checkboxes (again). With grouping bands this time
posted

Given: webgrid with 2 grouping bands, headers displayed for each. Typical view:

HEADER 0

     - row0 (band 0) [expanded]

           HEADER 1

                 row0 (band 1)

                 row1 (band 1)

      + row1 (band 0)

      + row2 (band 0)

The problem:

1) show checkbox column on postback (like do smth with selected rows) - solved

2) each row from band 1 has checkbox

3) HEADER 1 has checkbox to select all rows that relate to row 0 (band 0) and not other rows from band 1

This requirement is different from many other solutions found in forum.

The real problem is to get parent row (row 0 band 0 - in this case).

What didn't work (client-side): AfterCellUpdated (doesn't work for column header), Setting property on header checkbox and trying to find row with it - fails because this row isn't in grid.Rows collection

Server side code doesn't help either - we can get HeaderItem and no way to get row, because it's "virtual" from grid's view point.

The only way to solve this problem as i can see - go up in DOM using javascript and try to get some kind of row id. But doesn't seem 1)easy 2) reliable. Not sure if I can rely on id naming or anything like that.

Out of ideas.

Thanks.

 

[UPDATE]

It came to my mind that it could be possible to use other way to provide 'select all in subgroup' feature. Adding dumb row (client side only) with checkbox only, but not sure how to implement this. Grid is databinded

Parents
No Data
Reply
  • 349
    posted

    Solved this, but not really pretty.

    Did it relying on DOM structure generated for webGrid.

    Placing <input type=checkbox> in header, onclick handler locating parent <table>, then parent <tr> and its previous sibling (which corresponds to parent row). Using its id and igtbl_getRowById call gives you everything what's needed - child rows collection.

    The speed could be better, but I loop heavily, which could be replaced with some JS Framework nice queries.

    Still hope for better answer.

Children
No Data