I just finished a project where rows in a scrollable RadGrid would “break” on a subtotal line, and then continue on showing the next grouping /subtotal, etc. There could be a hundred groups/sub-totals on the grid. Also, my subtotal is the sum of those rows “selected via checkbox”, so as the user checks or unchecks boxes, the group subtotal recalculates. To do this with no postbacks:
1. The database query sorts the data, and unions in a subtotal row with amount (to minimize grid processing). Data and sub-total rows are labeled with 1/2, or a/b, or whatever. So the grid receives a prebuilt sub-total row.
2. ItemDataBound: If GridDataItem: hide checkboxes on sub-total rows (display or visible=false), sub-total row BackColor set to something cool, checkboxes on the data-rows are set “checked=true” (to match the sub-total amount) and JavaScript function is assigned to the OnClick event, and (optionally) alternating data rows are colored. My customers wanted pre-selected checkboxes. You can do however you wish – just make sure the sub-total amount is accurate.
3. JavaScript function is: Obtain checkbox, cell, row, rowIndex, table, and table.rows. Starting on current-row, go up to find beginning of our group (will hit prev group sub-total row label, or grid top), then go down to end of our group (look for sub-total label), summing when checkbox is checked (parseFloat the row’s innerText value after removing commas and dollar-signs, etc.). Write total to total-line (format to currency) and exit (to force two decimal currency format while reducing rounding errors, I multiply each row by 100, accum the amounts, and divide by 100 when writing).
The only challenge is if you need to use these updated sub-total amounts, because JavaScript wrote them and the grid seems to know nothing about them. Perhaps xmlHTTP, or a rad.label “Put” method?
Michael Goodwin