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 10:04 AM UTC

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 10:26 AM UTC

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 10:42 AM UTC

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 10:50 AM UTC

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 10:54 AM UTC

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 11:10 AM UTC

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 01:29 PM UTC

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 02:04 PM UTC

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 02:26 PM UTC

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 03:15 PM UTC

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 07:47 AM UTC

Thank you


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

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.
Up arrow icon