We are currently on Infragistics version 13.2 of win forms.
Our current implementation of the UltraWinGrid uses a combination of the following features:
- Row Filters
- Group by a single column
- An unbound column with data derived from a formula
- A custom summary on that unbound column that is itself derived from a formula Sum([a] - Sum([b]) / 100
FormulaRowIndexSource is not set (so it defaults to VisibleIndex)
On Application start, a data table is bound to the grid and all of the above happens except for the row filter value. Summary values are correct. However, when the user sets a filter value on the unbound column (i.e. <= 15000) upon filter evaluation the grid throws the following exception:
System.IndexOutOfRangeException: Index was outside the bounds of the array.
at Infragistics.Shared.SparseArray.ValidateIndex(Int32 index)
at Infragistics.Shared.SparseArray.GetItem(Int32 index, ICreateItemCallback createItemCallback)
at Infragistics.Shared.SparseArray.GetItem(Int32 index)
at Infragistics.Win.CalcEngine.UCRecalcChain.HSparseArray.get_Item(Int32 index)
at Infragistics.Win.CalcEngine.UCRecalcChain.get_Item(Int32 index)
at Infragistics.Win.CalcEngine.UCRecalcChain.RemoveDisposedReferences()
at Infragistics.Win.CalcEngine.UltraCalcEngine.DisposeReferences()
at Infragistics.Win.CalcEngine.UltraCalcEngine.ProcessTopologicalEvent(QueueInfo item)
at Infragistics.Win.CalcEngine.UltraCalcEngine.CleanTopologicalEventQueue(Int64 ticks)
at Infragistics.Win.UltraWinCalcManager.UltraCalcManager.Infragistics.Win.CalcEngine.IUltraCalcManager.ProcessEventQueue()
at Infragistics.Win.UltraWinGrid.RowsCollection.EnsureFiltersEvaluated()
at Infragistics.Win.UltraWinGrid.ScrollCountManagerSparseArray.VerifyAgainstScrollVersion()
at Infragistics.Win.UltraWinGrid.ScrollCountManagerSparseArray.get_VisibleCount()
at Infragistics.Win.UltraWinGrid.RowsCollection.GetVisibleRowCount(Boolean includeSpecialRows)
at Infragistics.Win.UltraWinGrid.RowsCollection.get_VisibleRowCount()
at Infragistics.Win.UltraWinGrid.UltraGridFilterRow.ApplyNewFiltersHelper(ColumnFilter origColumnFilter, ColumnFilter newColumnFilter, UltraGridFilterRow filterRow, Boolean fireFilterCellValueChangedEvent, RowsCollection rows)
at Infragistics.Win.UltraWinGrid.UltraGridFilterRow.ApplyNewFiltersHelper(ColumnFilter origColumnFilter, ColumnFilter newColumnFilter, UltraGridFilterRow filterRow, RowsCollection rows)
at Infragistics.Win.UltraWinGrid.UltraGridFilterRow.ApplyFilters(UltraGridColumn column, Boolean commitEditValues)
at Infragistics.Win.UltraWinGrid.UltraGridFilterCell.ApplyFilters()
Hi Chris,
I am just checking about the progress of this issue. Did Mike's suggestion helped you solve your issue? Let me know if you need my further assistance on this issue.
Thank you for using Infragistics Components.
I'm not saying it's forbidden, but it depends a lot on what your filters and formulas are. It's very easy to create a logical contradiction without realizing it.
As for the exclusion of hidden rows, the behavior you are seeing is correct. The FormulaRowSourceIndex determines whether the CalcManager deals with all rows or just the visible rows. So it's a catch-22.
One potential workaround, if you just want to get past this issue would be to create some unbound columns and set the value of the cells in those columns based on the visibility of the row.
So, for example, suppose you have a column (A) and you have a summary that does a Sum(A). You create an unbound column in the grid call A1. In the IntializeRow event of the grid you copy the value of (A) into the cell for (A1), but only if the row is visible. If the row is hidden, you copy a 0 into (A1). Now the sum of (A1) is the sum of only the visible rows in column (A). So you could use FormulaRowSourceIndex.RowIndex and everything would be fine.
Another option would be to forego using Formulas and the CalcManager entirely and use grid's build-in summary type like Sum. If you needed to do more complex calculations, you could write your own custom SummaryCalculator. This is, of course, a lot more work, but if you are under a deadline and just want to get this working, it might be worthwhile.
I'd be more than happy to set the FormulaRowIndexSource to RowIndex when filters are turned on. But as you can see in my example this renders my custom summary useless because it doesn't exclude the filtered out rows in it's calculation (like it does for the "standard" summary types like sum and max).
This would seem to imply that filtering is basically forbidden if you're using a custom (formula) summary. And if that's the answer I'm going to have a hard time explaining that to my manager.
I will try to take a look at your sample, but it would really be better if you had a sample duplicating the exception. The thing is, using Filtering and FormulaRowIndexSource.VisibleIndex can create a logical contradiction. Filtering bases the visibility of the row on a value of a cell, and the formula calculations will base the value of a cell or summary on the visibility of the row. So you can end up going on circles, which is why we generally recommend that you don't use VisibleIndex if you are doing filtering.
So solving the problem in the sample you provided here may not help you with your real issue, since they are not the same issue.
Hi Mike. Thanks for the reply.
I created a 13.2 sample project that as closely as possible demonstrates how we are using the ultra grid. Curiously, in the place where we get the index out of bounds exception, the sample project just hangs. But regardless I think it's adequate enough for demonstration purposes. The form itself contains instructions for running.
When I changed the references to point to 12.1 (sorry my initial post i accidentally said we were running 12.2, it's 12.1) while we see no issues in our application, I'm getting the same behavior as 13.2 I can't really explain why at this point, but I'm hopeful the example running against 13.2 is enough for you to go on. If it's not let me know and I will continue tweaking.
Thanks