Problem with Grouping the second time

This post has 7 Replies | 6 Followers

ygalanter
Points 1,290
Replied On: Mon, Aug 18 2008 10:20 AM

Hi, I am having problems when setting group-by columns in code. Here is a small snippet from InitializeLayout event:

oColumn = uwgGrid.Columns.FromKey(sColumnKey)
oColumn.SortIndicator = iSortIndicator
oColumn.IsGroupByColumn = True

I take several columns from the grid, set their sorting (ascending/descending) and set their IsGroupByColumn property to true (this adds the column to SortedColumns collection).

It works fine the first time, the groups are displayed properly. But when I do the same procedure the second time (same resultset is returned from database, same code executes in InitializeLayput event, same colums are used for grouping) I am getting error:

"Failed to compare two elements in the array."

Stack trace:

   at System.Array.BinarySearch(Array array, Int32 index, Int32 length, Object value, IComparer comparer)
   at System.Collections.SortedList.IndexOfKey(Object key)
   at System.Collections.SortedList.get_Item(Object key)
   at Infragistics.WebUI.UltraWebGrid.UltraGridLayout.RegisterGroupByColumn(UltraGridColumn groupedColumn)
   at Infragistics.WebUI.UltraWebGrid.UltraWebGrid.GroupRows(RowsCollection rows, UltraGridColumn column)
   at Infragistics.WebUI.UltraWebGrid.UltraWebGrid.SortGroupRows(RowsCollection rows)
   at Infragistics.WebUI.UltraWebGrid.UltraWebGrid.PerformGroupRows()
   at Infragistics.WebUI.UltraWebGrid.DBBinding.BindList(IEnumerable datasource)
   at Infragistics.WebUI.UltraWebGrid.DBBinding.DataBind(Object dataSource, String dataMember)
   at Infragistics.WebUI.UltraWebGrid.UltraWebGrid.DataBind()

 Inner exception:

"Object reference not set to an instance of an object."

Stack trace:

at Infragistics.WebUI.UltraWebGrid.UltraGridLayout.GroupByColumnComparer.Compare(Object x, Object y)
at System.Array.BinarySearch(Array array, Int32 index, Int32 length, Object value, IComparer comparer)

I've tried to clear the grid completely before the second call, as well as clearing SortedColumns collection - it doesn't help. I am using NetAdvantage 2006 Vol. 3 CLR 2.0.

Any help is greatly appreciated.

  • Post Points: 20
JRossi123
Points 65
Replied On: Tue, Dec 2 2008 3:26 PM

You may need to reset the columns, rows and bands.  For example:

UltraWebGrid1.ResetBands()

UltraWebGrid1.ResetColumns()

UltraWebGrid1.ResetRows()

 

 

 

  • Post Points: 55
ygalanter
Points 1,290
Replied On: Tue, Dec 2 2008 3:29 PM

THANKS!

That did the trick ;)

  • Post Points: 5
ygalanter
Points 1,290
Replied On: Fri, May 8 2009 2:08 PM

After uprading to 2009.1 for CLR2.0 (with hotfix 2013) the error started to happen again. So far I've been unsuccessful in solving it. Any help is appreciated.

  • Post Points: 20
abromfield
Points 555
Replied On: Sun, Jun 28 2009 3:02 PM

I am experiencing the same issue, despite calling WebGrid.ResetBands(), WebGrid.ResetColumns() and WebGrid.ResetRows() before binding the WebGrid.  Is there a fix for  this issue yet?

 

  • Post Points: 20
badbart
Points 100
Replied On: Wed, Jul 8 2009 12:31 PM

Normal 0 false false false MicrosoftInternetExplorer4

I did not encounter "Failed to compare two elements in the array." until I started using ResetBands(), ResetColumns(), & ResetRows(). So I tried to solve the grouping on rebind problem without them.

 

I discovered that grouping occurs only when the value of IsGroupByColumn changes from False to True. If it is already true before the DataBind() then no grouping occurs when PerformGroupRows() is called a second time (bug?).

 

UltraWebGrid1.DataBind()

UltraWebGrid1.Columns.FromKey("MyGroupingColumn").IsGroupByColumn = False

UltraWebGrid1.Columns.FromKey("MyGroupingColumn").IsGroupByColumn = True

UltraWebGrid1.PerformGroupRows()

UltraWebGrid1.ExpandAll(True)

  • Post Points: 20
10eSolutions
Points 200
Replied On: Mon, Oct 19 2009 11:13 AM

Thank you so much - I was having the same problem. 

Setting all the IsGroupBys to false before rebinding, and then setting them to true again where appropriate stopped my crashing!

  • Post Points: 20
navadeeptsmtm
Points 145
Replied On: Wed, Mar 10 2010 1:47 AM

Hi,

I am also getting the same error. Can anybody suggest a solution for this. I have done all the above suggested. 

Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerServerErrorException: Failed to compare two elements in the array.

This is the error i am getting while second time grouping.

  

 

  • Post Points: 5
Page 1 of 1 (8 items) | RSS