Hi,
I have two grids - summary and history. On selecting summary row, I need to determine the summary type and based on it hide/show some columns and change the order of some columns in history grid. InitializeLayout is working only on load but not dynamically.
How can I do this in a code?
Thanks
Victor
Hi, vkuzmich
UltraGridColumn has Hidden property. Use it to hide the corresponding columns.
grid.DisplayLayout.Bands[0].Columns["MyColumn"].Hidden = true
Also you need to use column.Header.VisiblePosition, that returns or sets the position of the column within its group, if the column belongs to a group, or its band, if the column belongs to a band.
grid.DisplayLayout.Bands[0].Columns["MyColumn"].Header.VisiblePosition = 5; //set the position you need.
Alex.
Thank you Alex.
Forgot to tell you that show/hide is working with Hiden property.
However, VisiblePosition is not working. I have this
gridSummary_AfterRowActivate (...)
{
if (type1)
gridHistory.DisplayLayout.Bands[0].Columns[
"AssociateName"].Header.VisiblePosition = 0;
....more code...
}
else
"AssociateType"].Header.VisiblePosition = 0;
....more code....
But the column order is not changing. It should be based on the value of type1. And type1 is kind of type of the summary record.
Note that you must set the columns in order so as to prevent the positoin of one column from interfering with another.
Alex
Sure. This is why I am strting with 0.
Hi VK,
vkuzmich said: I had UseRowLayouts set to true. I changed it to false and column reordering is working now. Probably I set UseRowLayouts to true when I was configuring it to have multiline cells. Looks like I don't need it to be set to true.
I had UseRowLayouts set to true. I changed it to false and column reordering is working now.
Probably I set UseRowLayouts to true when I was configuring it to have multiline cells. Looks like I don't need it to be set to true.
Just so you know, it is possible to use RowLayouts and still use the VisiblePosition property. If the RowLayaoutColumnInfo on the column does not have an OriginX assigned to it, then the grid will fall back to using the VisiblePosition. So at some point, you must have not only turned on RowLayouts, but also modified the layout. You may have set the RowLayoutColumnInfo.OriginX explicitly, but more likely you just dragged some columns around in the designer and that's what set the property. So you could leave RowLayouts on and just Reset the OriginX on each column and that should work.
vkuzmich said:BTW, is there any doc or something where I can look into to find such information? I wasted so much time on such simple issue :-(
I guess the VisiblePosition property documentation should mention this. I will send a link to this thread over to our documentation team and ask them to update the docs.
Thank you Mike.
This is the answer of EXPERT.
BTW, is there any doc or something where I can look into to find such information? I wasted so much time on such simple issue :-(
Thank you.
VK
The only reason I can think of why VisiblePosition would not work is if you are using a RowLayout. If UseRowLayouts on the band is true, then the VisiblePosition is overrided by the RowLayoutColumnInfo properties on the column. So in the case, you would have to adjust the layout in code, which is much more complicated.