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

Sorting on an Index of a Collection?

3 Answers 40 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rossonero
Top achievements
Rank 1
Rossonero asked on 14 Jun 2010, 10:07 PM
I am having trouble sorting when the SortExpression is set to Object[i].Property

Scenario:

My Site class has a property of type Collection<Estimate> Estimates
The Estimate class has a Decimal property called Total

After executing a search, I am binding the radGrid to a collection of Site objects that fit the criteria
ie: gvResults.DataSource = Collection<CustomSite.Site>

When executing the search query, the Estimate collection above gets filled with up to 3 types of estimates. One of these types is very important, and is always added to the collection in the first position.

When creating the grid, I have a column defined as

<telerik:GridBoundColumn DataField="Estimates[0].Total" HeaderText="Estimate Total" SortExpression="Estimates[0].Total" DataFormatString="{0:n0}" DataType="System.Decimal" HtmlEncode="False" HeaderStyle-Width="86px" ItemStyle-Width="86px" ItemStyle-HorizontalAlign="Right" ItemStyle-VerticalAlign="Top" SortAscImageUrl="~/Images/sort-up.gif" SortDescImageUrl="~/Images/sort-down.gif" />

I have a second column defined the same way, it just binds to a different property

<telerik:GridBoundColumn DataField="Values.Equipment" HeaderText="Equipment" SortExpression="Values.Equipment" DataFormatString="{0:n0}" DataType="System.Decimal" HtmlEncode="False" HeaderStyle-Width="86px" ItemStyle-Width="86px" ItemStyle-HorizontalAlign="Right" ItemStyle-VerticalAlign="Top" SortAscImageUrl="~/Images/sort-up.gif" SortDescImageUrl="~/Images/sort-down.gif" />

The cells in both cases are filled with the correct value after the search binds.

I have no trouble sorting on the Values.Equipment column. Ascending, descending, it works find both directions.

However, when I try to sort on the Estimates[0].Total column, I get very strange and entirely incorrect results.

The odd thing is that if I sort ASC, maybe one or two rows will shift from their default position, but not in the sort position specified. If I sort DESC, I may or may not get a change. If I sort ASC again, the rows may still stay the same, or they may shift to yet a different position from the first ASC sort and still different from the original sort.

Is it not possible to have a SortExpression defined as an indexed value of a collection (ie: Estimates[0].Total)

More code can be posted if necessary.
                                
                                

3 Answers, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 18 Jun 2010, 06:58 AM
Hi Rossonero,

Can you provide a sample runnable code illustrating your scenario (grid declaration and binding) using dummy data for instance? We will test it and turn back to you with our findings.

Looking forward your reply,
Iana
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Rossonero
Top achievements
Rank 1
answered on 18 Jun 2010, 03:03 PM
Iana,
I submitted a support ticket with a very small sample attached that illustrates the problem.



Your ticket ID is: 320254
0
Iana Tsolova
Telerik team
answered on 22 Jun 2010, 10:10 AM
Hi Rossonero,

Thank you for opening a formal support ticket and for providing a runnable sample there. 
We  will debug it and turn back to you with our findings.

All the best,
Iana
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
Rossonero
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
Rossonero
Top achievements
Rank 1
Share this question
or