We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

How can I reset the column order on a GridGontrol?

I've discovered the following methods for resetting the grouped columns, filters, and sorted columns, but I haven't found one for resetting the original column order. What's the easiest way to do this? I really don't want to persist the original grid state to disk.

DealGridControl.GroupedColumns.Clear();
DealGridControl.ShowFilters = false;
DealGridControl.SortColumns.Clear();

Thanks in advance,
Will. 

4 Replies

RG Rajasekar G Syncfusion Team December 26, 2012 10:45 AM UTC

Hi Will,

 

We have analyzed your requirement and we have achieve your requirement by using the following code snippet.

 

Code Snippet[C#]:

private void Order_Click(object sender, RoutedEventArgs e)

{

    foreach (KeyValuePair<int,string> it in Vcolorder)

    {

        int fromindex = this.SyncGrid.VisibleColumns.IndexOf(this.SyncGrid.VisibleColumns[it.Value]);

        this.SyncGrid.VisibleColumns.Move(fromindex,it.Key);                        

    }

}

 

We have prepared a sample based on this and it can be download from the following location.

 

Sample Location: GridDataControl_VisibleColumn.zip

 

Note:

·         Run the sample .

·         Re arrange the column by Column drag and drop.

·         Click the button Arrange order to rearrange the visiblecolumn

 

Please let us know if you have any questions.

 

Regards,

Raja sekar.G



WR Will Rogers January 4, 2013 02:59 PM UTC

Thank you. I will give this a try when I am next able to work on this.


WR Will Rogers January 16, 2013 06:16 PM UTC

Thanks, that method worked but is sub-optimal from a user standpoint. It would be really nice if you just exposed a Reset() method on the GridDataControl that resets the sorting, grouping, ordering, and filtering. How do I go about formally requesting that feature?

If you don't mind a related follow up, I'm now having trouble resetting the Filters on the VisibleColumns. I'm trying to do this:

for (int i = 0; i < gridDataControl.VisibleColumns.Count; i++)
{                                                                      gridDataControl.VisibleColumns[i].Filters.Clear();
}

But at certain points in my app the VisibleColumns.TableModel is null and the operation blows up with a null ref exception during your call to ApplyFilter().

Any suggestions?


RG Rajasekar G Syncfusion Team January 24, 2013 05:10 AM UTC

Hi Will, 

Sorry for the delay in getting back to you. 

Could you please create new incident for feature request through Direct Trac system and we will update the status of this through incident. 

Direct Trac Link : https://www.syncfusion.com/account/login?ReturnUrl=%2fsupport%2fdirecttrac%2fincidents 

And also could you please share the following details with us in the Direct Trac incident .That would be very helpful for us to further analysis to provide the solution for the issue “Null Exception occur while using VisibleColumns collection”    

·         Could you please share your simple sample to replicate the issue.

·         In which scenorio do you clear the filters from the VisibleColumn.

 

Please let us know If you have any questions.  

Regards,

Raja sekar.G


Loader.
Live Chat Icon For mobile
Up arrow icon