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

RadFileExplorer Grid column sorting

1 Answer 128 Views
FileExplorer
This is a migrated thread and some comments may be shown as answers.
Rajeev
Top achievements
Rank 1
Rajeev asked on 14 Jul 2011, 05:04 PM
Hello All,

I have a RadFileExplorer in our application which is created dynamically. The grid has two bound columns for which we have to enable column sorting. I have registered the GridSortCommandEventHandler while creating the Grid but the grid is not triggering the Sort event.

radFileExplorer.Grid.ID = radGridViewName;

radFileExplorer.Grid.AllowSorting = true;  
radFileExplorer.Grid.ItemDataBound += new GridItemEventHandler(radFileExplorer_ItemDataBound);  
radFileExplorer.Grid.SortCommand += new GridSortCommandEventHandler(radFileExplorer_SortCommand);  
radFileExplorer.TreeView.NodeClick += new RadTreeViewEventHandler(treeView_NodeClick);

Below is the code written for radFileExplorer_SortCommand event. The below event is not getting invoked on click of the column header.

void

radFileExplorer_SortCommand(object sender, GridSortCommandEventArgs e)  

{

string sortDir = "ASC";  
DataView dv = new DataView(Documents);  
string viewStateKey = "sortDirection" + e.SortExpression;  
if (ViewState[viewStateKey] != null)  

{
sortDir = ((string)ViewState[viewStateKey] == "ASC") ? "DESC" : "ASC";  
}

ViewState[viewStateKey] = sortDir;
dv.Sort = e.SortExpression + 

" " + sortDir;  
SortExpression = dv.Sort; 
GridView docListGrid = (GridView)this.FindControl(radGridViewName);  
if (docListGrid != null)  
{

docListGrid.DataSource = dv;

docListGrid.DataBind();

}

}

This is quite urgent and any help would be appriciated.

Many thanks in advance.

Regards
Rajeev



1 Answer, 1 is accepted

Sort by
0
Dobromir
Telerik team
answered on 18 Jul 2011, 09:37 AM
Hi Rajeev,

The grid component of RadFileExplorer is using client-side binding, that is why the SortCommand event is not fired. You can assign handler to the grid's ClientCommand client-side event to apply custom logic during the event, e.g.:
<telerik:RadFileExplorer ID="RadFileExplorer1" runat="server" OnClientLoad="OnClientLoad">
    <Configuration ViewPaths="~/" />
</telerik:RadFileExplorer>
 
<script type="text/javascript">
    function OnClientLoad(oExplorer, args)
    {
        var grid = sender.get_grid();
        grid.add_command(sortCommandHandler);
 
    }
 
    function sortCommandHandler()
    {
        if (args.get_commandName() == "Sort")
        {
            //add custom code here
        }
    }
</script>

I hope this helps.

Regards,
Dobromir
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Tags
FileExplorer
Asked by
Rajeev
Top achievements
Rank 1
Answers by
Dobromir
Telerik team
Share this question
or