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

Simulating windows explorer sorting

3 Answers 87 Views
GridView
This is a migrated thread and some comments may be shown as answers.
superold
Top achievements
Rank 1
superold asked on 18 Dec 2008, 02:18 AM
Hi

I am trying to simulate the ordering of "details view" on windows explorer (Vista). That is, all the folders are grouped together.

I have the name, date, type, size columns and a "isfile" which is not shown, although one could use the fact that size is string.empty. Anyhow, I have been trying with SortExpressions but to no avail. Take a look at my tests.

        private void radGridView_SortChanged(object sender, GridViewCollectionChangedEventArgs e)
        {
            if (e.GridViewTemplate.SortExpressions.Count > 0) // clear does trigger sortchanged
            {
                if (e.GridViewTemplate.SortExpressions.IndexOf("IsFile") == -1) // already added?
                {
                    e.GridViewTemplate.SortExpressions.Insert(0, new GridSortField("IsFile", e.GridViewTemplate.SortExpressions[0].SortOrder)); // force it to be the most important expression
                }
            }
        }

Any ideas?

Thanks
-jorge
VS2005, 2008Q3 1204

3 Answers, 1 is accepted

Sort by
0
Julian Benkov
Telerik team
answered on 19 Dec 2008, 03:47 PM
Hello Jorge Delgado-Lopez,

You can use and extend the data model used in our Explorer QSF example for this scenario.

If you have additional questions, please contact us again.

Best wishes,
Julian Benkov
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
superold
Top achievements
Rank 1
answered on 19 Dec 2008, 08:43 PM
Hi,

The sample "vista explorer" doesn't fit my needs.

My problem right now is sorting, and the sample does not supply any sortexpression examples.

Thanks,
-j
0
Julian Benkov
Telerik team
answered on 22 Dec 2008, 05:08 PM
Hi Jorge,

The solution with string.Empty for the Folder presentation in the 'IsFile' column will work fine for sorting. This approach requires your data to always set string.Emty for Folder type and some string for File type, like FileName as example.

To support grouping you should add a GroupByExpresion to the RadGridView, but this will not allow for sorting. Group By operation takes care of the sorting automatically.

this.radGridView1.MasterGridViewTemplate.GroupByExpressions.Add("IsFile Group By IsFile"); 
 
 


Kind regards,
Julian Benkov
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
GridView
Asked by
superold
Top achievements
Rank 1
Answers by
Julian Benkov
Telerik team
superold
Top achievements
Rank 1
Share this question
or