This is a migrated thread and some comments may be shown as answers.

RadGrid Save Settings on Groupings

2 Answers 164 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Patrice
Top achievements
Rank 1
Patrice asked on 24 Mar 2014, 07:55 PM
I have referenced the following code for saving grid settings for users
http://www.telerik.com/help/aspnet-ajax/grid-saving-settings-on-per-user-basis.html

All works well. However, when saving the object for grouping settings your page above suggests the following code:

Protected Overridable Sub SaveGroupByExpressions()          
  Settings.GroupByExpressionsStates =
New Object(Grid.MasterTableView.GroupByExpressions.Count) {}           
  Dim i As Integer = 0           
  While i < Settings.GroupByExpressionsStates.Length             
    Settings.GroupByExpressionsStates(i) =(
DirectCast(Grid.MasterTableView.GroupByExpressions(i),IStateManager)).SaveViewState()                               System.Math.Max(System.Threading.Interlocked.Increment(i), i - 1)
   
End While       
End Sub

In the while statement the i variable is used for both the GroupByExpressionsStates index and the GroupByExpressions index.
If only one GroupBy expression is selected by the user, then the GroupByExpressions.Count  = 1 and the the object length = 2.
When going through the loop, it fails because once past the first index of 0, there is no group expression for Grid.MasterTableView.GroupByExpressions(1).

I'm trying to figure out why the empty object created by the statement:
Settings.GroupByExpressionsStates = New Object(Grid.MasterTableView.GroupByExpressions.Count) {}
is creating a Settings.GroupByExpressionsStates object with 2 empty arrays when only 1 is needed for this example?

Please see the attachments.

2 Answers, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 27 Mar 2014, 01:27 PM
Hello Mark,

Thank you for contacting Telerik Support.

I have tested the scenario that you are describing and indeed, in VB, two objects are created in the objects array if you use New Object(1). Please note that in C# this will create only 1 object and it will work correctly.

I am assuming that when the help article was created, that part of the VB code was not correctly examined and I will forward that issue accordingly, so it could be fixed in the help article.

For the time being you should use the following line instead:
Settings.GroupByExpressionsStates = New Object(Grid.MasterTableView.GroupByExpressions.Count - 1) {}

Please let me know if any further assistance is needed on this matter.


Regards,
Konstantin Dikov
Telerik
 

Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.

 
0
Patrice
Top achievements
Rank 1
answered on 01 Apr 2014, 08:33 PM
Awesome. I should've saw that. Thanks!
I was trying to adjust the index later on instead of in the new constructor.... ach!
Again, Mucho mucho gracias.
Tags
Grid
Asked by
Patrice
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Patrice
Top achievements
Rank 1
Share this question
or