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

issues on a columns.changing event in a gridgrouping control

Hello. I''m trying to hide/show the columns of my gridgroupingcontrol. It works well with: theGrid.TableDescriptor.VisibleColumns.Remove(colName); But i have an issue with the theGrid.TableDescriptor.Columns.Changed event. After hiding a column it s never launch. This is a bug? Thnak you.

12 Replies

AD Administrator Syncfusion Team March 31, 2005 05:04 AM

Removing a column from the TableDescriptor.VisibleColumns collection does not affect the items in the TableDescriptor.Columns collection. Try catching the TableDescriptor.VisibleColumns.Changing event to see if that gives you waht you need.


JG Julien Goldberg March 31, 2005 05:26 AM

In fact after hide/show a column i''m trying to move the columns. But neither columns.changing(ed) and visiblecolumns.changing(ed) are launched.


AD Administrator Syncfusion Team March 31, 2005 05:42 AM

What verswion of our code are you using? With 3.0.1.0, if I subscribe to these events: this.gridGroupingControl1.TableDescriptor.VisibleColumns.Changed += new Syncfusion.Collections.ListPropertyChangedEventHandler(VisibleColumns_Changed); this.gridGroupingControl1.TableDescriptor.VisibleColumns.Changing += new Syncfusion.Collections.ListPropertyChangedEventHandler(VisibleColumns_Changing); And in a button handler, have this code:
private void button1_Click(object sender, System.EventArgs e)
{
	GridVisibleColumnDescriptor cd = this.gridGroupingControl1.TableDescriptor.VisibleColumns["ParentName"];
	this.gridGroupingControl1.TableDescriptor.VisibleColumns.Remove(cd);

	this.gridGroupingControl1.TableDescriptor.VisibleColumns.Insert(0, cd.Name);
}
There event handlers are hit for me.
private void VisibleColumns_Changed(object sender, Syncfusion.Collections.ListPropertyChangedEventArgs e)
{
	Console.WriteLine("VisibleColumns_Changed" + e.Action.ToString());
}

private void VisibleColumns_Changing(object sender, Syncfusion.Collections.ListPropertyChangedEventArgs e)
{
	Console.WriteLine("VisibleColumns_Changing" + e.Action.ToString());
}


JG Julien Goldberg March 31, 2005 05:50 AM

These events are hits when you hide/show a column. But i''m trying to catch the event when i change the order of the columns.


JG Julien Goldberg March 31, 2005 05:54 AM

An example: i open the window with my gridgroupingcontrol. If I move a column, the visiblecolumns.changing/ed events are not hit. But if i hide a column then i move a column they are hit.


AD Administrator Syncfusion Team March 31, 2005 06:10 AM

If you are using the UI to move a column, try catching this.gridGroupingControl1.TableDescriptor.Columns.Changing += new Syncfusion.Collections.ListPropertyChangedEventHandler(Columns_Changing); It is hit for me in 3.0.1.0 using code similar to that I listed above.


JG Julien Goldberg March 31, 2005 08:29 AM

Hi. I have tested in a seperate project these events. When i move a column it''s the column_chamged/ing event which is hited. But, if i hide/show (remove/add) a column and then, i move the columns it''s always, and only, the visible_columns.changed/ing which is hited. The behavior seems to me strange, but perhaps it''s normal.


AD Administrator Syncfusion Team March 31, 2005 09:04 AM

Here is how the Stefan explains it. When you drag columns with the UI the grid checks if the VisibleColumns collection was marked modified. In that case the column will be rearrange in the VisibleColumns collection. If the VisibleColumns collection is set to default and not marked modified then the Columns collection will be modified itself and the VisibleColumns will simply reflect the changes – therefore you need to listen to both VisibleColumns.Changing and Columns.Changing event. When you move columns with UI one of those two events will get hit. Which one is depending on whether the VisibleColumns collection was modified or not.


JG Julien Goldberg March 31, 2005 09:26 AM

Thanks for the explanation. Just one more question. There is a way to mark as "unmodified" the columns collection after hiding or showing a column? >Here is how the Stefan explains it. > >When you drag columns with the UI the grid checks if the VisibleColumns collection was marked modified. In that case the column will be rearrange in the VisibleColumns collection. > >If the VisibleColumns collection is set to default and not marked modified then the Columns collection will be modified itself and the VisibleColumns will simply reflect the changes – therefore you need to listen to both VisibleColumns.Changing and Columns.Changing event. > >When you move columns with UI one of those two events will get hit. Which one is depending on whether the VisibleColumns collection was modified or not. > >


AD Administrator Syncfusion Team March 31, 2005 10:15 AM

You can call Columns.Reset. This will reload the columns from the which may not be what you want. Another option might be to initially call VisibleColumns.LoadDefault. This will populate the VisibleColumns collection and mark it as modified so then its events will be raised.


CV Charles Vinoth March 30, 2018 02:47 AM

Thank you


AR Arulpriya Ramalingam Syncfusion Team April 2, 2018 12:10 AM

Hi Charles, 
 
Thanks for the update. 
 
We are glad that the provided solution resolved your use case. Please let us know, whether you need any further assistance on this. 
 
Regards, 
Arulpriya 


Loader.
Live Chat Icon For mobile
Up arrow icon