How do I freeze a column from scrolling with the rest of the data. I want to display a grid with the last columns always visible. The rest of the data must scroll left or right without the last columns moving.
Thank you
You can do this with Fixed headers. Set UseFixedHeaders to true and then set the Fixed property on the column header(s) you want to fix. I would do all of this in the InitializeLayout event of the grid.
thanks
I also did the same in the initializelayout. The first 5 columns are freezed. But when i change my data source the columns order also changes. If i comment out the freeze column code, it works perfectly fine. Any idea?
I don't understand what you mean. The frozen columns have to be moved over to the left, so the column order will change. There's no way around that.
If you mean the order of the columns within the fixed and unfix section, you can control the order of the columns by setting the column.Header.VisiblePosition property. It's a good idea to set these in order from 0 up to avoid having the setting on one column affect any other columns.
Let me repharase my question.
I am calling Ultragrid1.datasource = datatable in the form load event. The datatable contains 21 cols which are dynamically bind to data grid. Now in InitializeLayout of UltraGrid i am freezing first 5 columns as below.
e.Layout.UserFixedHeader=true;
for(int i=0;i<5;i++)
{
e.Layout.Band[0].columns.Header.Fixed=true;
}
The Good thing is first 5 cols are Freezed now. I have also one dropdown box which contain 3 values. Each value changes the datasource of UltraGrid on SelectedValueChange Event. So when i change the datasource property to the new values in datatable. the order of the cols also changes.
Note: The datatable contains the same cols with exact name and order only value is different.
The strange thing is if i comment out the above loop for freezing 5 cols, it works perfectly fine.
Thanks.
mhornby said:What code needs to be used to freeze columns within an ultrawebgrid?
What code needs to be used to freeze columns within an ultrawebgrid?
You should post this question in the UltraWebGrid forum.
Instead of setting the DataSource property on the grid, try calling SetDataBinding, instead and see if that helps.
If not, it sounds like a bug in the grid. The grid must be doing something in the wrong order when binding the new columns in the data source with the existing columns in the grid. You should try to duplicate this in a small sample project and Submit an incident to Infragistics Developer Support.
In the mean time, you can try working around it by either explicitly setting the VisiblePosition on each column header as I mentioned before. Or, try saving the grid's layout (using grid.Layout.Save) before you set the DataSource, then re-load the layout afterward.