Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
180
Webdatagrid sorting within folders/files
posted
Hi There, 
                I would like to bind the directories and files information into webdatagrid (refer to attached the layout of my webdatagrid) and in that, the sorting should works within the directories first and files then for ascending. In case of descending the files should be shown in top followed by the directories and the sorting should be applied within the types (directories/files).Can anyone help me out to achieve this kind of sorting in the webdatagrid? It would be great of help if provide with a sample or piece of code required to.
Parents
  • 33839
    Suggested Answer
    posted

    Hi Simbu,

    Even though you want only one column sorted, you're actually performing a multi-sort.  First by the type of info (directory or file), and then by name.  As such, you can have the data grid do this for you.  What you will need to do is add another bound data column that has this type for each row.  You can sett Hidden="true" on it so that the end user cannot see it.  You'll also need to set SortingMode to multi on sorting.  Then in the ColumnSorted Server event, you'll want something like this.  Your type col could be a string with "dir" and "file" for values to get the sorting you see in your picture or even just an int with "0" and "1".

    protected void WebDataGrid1_ColumnSorted(object sender, SortingEventArgs e)
        {
            if (e.Column.Key == "Name")
            {
                Infragistics.Web.UI.SortDirection dir = e.SortedColumns[e.Column.Key].SortDirection;
                e.SortedColumns.Clear();
                e.SortedColumns.Add("Type", dir);
                e.SortedColumns.Add(e.Column.Key, dir);

            }

    }

    Let us know if you have any trouble getting this to work.

    regards,
    David Young

Reply Children
No Data