When i move column position, visibleindex remain unchanged
I am handling AfterColumnMove event to find the column visble location. but it remains unchanged
where can i actually get this?
Hi Mike
Thanksfor the response.
i referred impact on performance? since, we are loading all grid settings from DB, there are many, settings in one go before opening the App.
when i build what i required, resulting around 1 kb size.
strange, i was doing the same. probably i am using V8.3. anyhow, thanks for the reply
pvm444 said:size of generated XML is around 11.1kb, so obviously this is huge impact on performance.
Why is that a "huge impact on performance"? 11.1KB is practically non-existant. :) If you want a smaller file, you could save the binary instead of XML.Also, I think you want to use the Bands option, rather than SortedColumns, since you are not interested in saving the sorting. Sorting here refers to the SortIndicator property on the column which sorts the rows, it's not the order of the columns.
But I really don't see how 11.1 KB could possibly have any significant impact on performance, unless you are saving the layouts of 1000+ grids at once.
Of course, saving the grid layout saves a lot more than just the order. It includes things like the position and width of each column, the sorting and filtering, etc. But typically, these are things you want to save.
Anyway, though, I tried this out with the following code and it works fine for me:
private void ultraGrid1_AfterColPosChanged(object sender, AfterColPosChangedEventArgs e) { UltraGrid grid = (UltraGrid)sender; foreach (UltraGridColumn column in grid.DisplayLayout.Bands[0].Columns ) { Debug.WriteLine(column.Header.VisiblePosition, column.Key); } }
Note that the order of the columns in the Columns collection does not change, but the VisiblePosition is returning the correct number for every column in my case. I'm using v9.1 of the grid with the latest service release, of course.
Hi Mike,
Thanks for the reply
Yes, you are right, i am talking about AfterColumnMove event and VisibilePosition property.
Hmm... i am not using RowLayouts.
my requirement is simple, have to save grid settings ( only column position, and column visibility) to DB. if i use this code
grid.DisplayLayout.SaveAsXml(stream,PropertyCategories.SortedColumns)
, size of generated XML is around 11.1kb, so obviously this is huge impact on performance.
so i decided to build myself . so wire up at AfterColPosChanged
[Sample code]
this.AfterColPosChanged += (sender, e) => { OnLayoutChanged( ); };
string OnLayoutChanged(UltraGrid gridControl )
{
XmlDocument doc = new XmlDocument( );
XmlElement rootElement = doc.CreateElement(gridControl.Name);
doc.AppendChild(rootElement);
foreach (UltraGridColumn item in gridControl.DisplayLayout.Bands[0].Columns)
string nodeName = GetFormattedNodeName(item.Key);
XmlElement e = doc.CreateElement(nodeName);
e.SetAttribute(index, item.Header.VisiblePosition.ToString( ));
e.SetAttribute(visible, item.Hidden.ToString( ));
rootElement.AppendChild(e);
}
but, visibleposition is not changing when i move/swap the column
do you think did i missed something?
Hi,
I'm afraid I do not understand your question. There is no AfterColumnMove event in the WinGrid. There is an AfterColPosChanged event. Is that what you meant?
If so, then what property are you looking at, and on what object? There is no VisibleIndex property on the column. There's a VisiblePosition on the Column Header. If that's what you meant, then the only reason I can think of why this would not be updated is if you are using RowLayouts in your grid - in which case the VisiblePosition is not used in favor of the RowLayoutColumnInfo on each column.