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
3045
Is it possible to specify which rows to summarize in UltraGrid?
posted

My grid has selection checkboxes on the left. I just want to apply the summary to those that are checked. Is there an event that I can catch while the summary is being calculated to skip unchecked rows?

Thanks,

Version: 9.2

  • 469350
    Offline posted

    Hi,

    jquerijero said:
    Is there an event that I can catch while the summary is being calculated to skip unchecked rows?

    Well.. kinda. There's no event, but there are a couple of ways you could achieve this.

    The first way would be to use an unbound column. What you do is use the grid's InitializeLayout event to add an unbound column. Set this column's DataType to the same DataType as the column you want to summarize. You can hide this column (via the Hidden property).

    Then you can use the InitializeRow event to populate the unbound column with a value. You examine the checkbox, and if it's checked, you copy the value from the real column into the unbound column. If it's uncheck, you set the value of the unbound column to 0.

    Then you summarize the unbound column.

    This approach will work well for summing up a column, but it won't work for calculations that depend on the number of rows, such as an average.

    So another option would be to use a custom summary with an ICustomSummaryCalculator. This interface fires off methods which are very much like events. You get a method when the summary calculation begins, one when it ends, and one for each row. So you could ignore certain rows.