After setting up my grids at design time, if a few months later somebody adds a property to the datasource object it will automatically appear in the grid. Is there an attribute or something we can add to the properties that we don't want to show in the grid?
Hello,
It's possible that certain types of data sources have a way to hide specific fields from the controls to which they are bound. However, I have not personally used any data source with such an option.
By default, UltraGrid will use the fields in the data source to define its schema. You can override this behavior by defining a schema beforehand and telling the grid to use its predefined schema instead of creating a new one from the new data source. Since you already have your data source, you can use it to automatically define the schema first, then bind to the data itself later. In order to do this, take the following steps. I am assuming that you are doing this in the designer and starting with a databound grid:
ultraGrid1.DisplayLayout.NewColumnLoadStyle = Infragistics.Win.UltraWinGrid.NewColumnLoadStyle.Hide;ultraGrid1.DataSource = ultraDataSource1;
Please let me know whether this solution works for you.
I understand we could do that through code. We have thousands of ultragrids and ultracombos that we setup in design time. So if your suggestion is the only way to do it, then what is the point of setting everything at design time and getting everything perfect then having to add a new property to an object throws off every grid or combo that we have created based on that object. It just seems like there should be a way after setting up the grid, that it will lock it to look the way we want. Is there something simple like adding an attribute to the objects property that tells infragistics to ignore the property.
Depending on what type of datasource you're using, you might be able to hide specific fields. There's a good way to do it in the grid, though, which is independent of the type of datasource you use.
After binding the grid, loop through the columns in each band and set the column's Hidden property to false. Then, set Hidden back to true for the specific columns you want to show. If new columns are added to the data source, they'll be picked up by the initial loop and hidden, but won't be set back to visible unless you modify the code to do so.
Please let me know if you have any questions.