I'm using Q3 2008 version, my problem is: In design-time i added 2 columns (code, description) with its properties and datafield information. I need so because I hide some columns when it's needed. When running, fill a dataset and databind it to the datasource gridview, and when data is shown, I see 4 columns (code, description, code, description), How can I do to solve this, as in 2007 version it didn't happen to me?, thanks!
NOTE: I cannot see AutoGenerateColumns In the properties under MasterGridViewTemplate in design-time
10 Answers, 1 is accepted
Setting
myRadGridView.MasterGridViewTemplate.AutoGenerateColumns =
false;
fixes the problem, but I have to do it in code. I believe this property should be available directly on GridView (top level) and should be settable in design-time so it is serialized into designer code and it does not need to be explicitly set in the code.
Cheers,
Daniel
Indeed, the AutoGenerateColumns will turn off the automatic generation of the columns based on the data source, as Daniel has demonstrated.
However, hiding the AutoGenerateColumns property in design time is deliberate (it is also hidden in the standard DataGridView control). Since the RadGridView uses this functionality in design time to allow the user to perform additional customization of the grid's columns, it should be hidden and have default value set to true.
I hope this helps.
Best wishes,
Deyan
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
I found it by code, but I think it should exist in desing-mode due to is up to the programmer to set to suitable value
This property works as expected. We decided that it should be hidden, because in case the user sets it to false via the designer, the functionality that enables the design time grid customization will not behave properly since the designer relies on the automatic column generation.
Best wishes,
Deyan
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Hi Deyan,
something must have changed since it didn't behave this way before Q3 2008 SP2.
Regardless, I think this is commonly used procedure used by those, who use RadGridView and its autogeneration functionality. You set datasource with auto generating turned on. Grid generates columns according to data source just set. Then, developer modifies this columns via Property Builder (or designer in general) and saves these changes. From now on, we don't want columns to be generated again. So, at this point (and it behaved like this until Q3 SP2), we want auto generate turned off or at least not altering columns at all. We don't want generator to override our settings in run-time.
So something should change here, the way it works is not logical nor convenient.
Cheers,
Daniel
Yes, we changed the visibility of this property, as I said earlier. We decided so because of some conceptual reasons one of which is that the Microsoft DataGridView uses this approach, as well.
When you bind the RadGridVew to a data source in design time the columns are automatically generated and populated. You can freely modify their appearance, order and visibility. When you save the changes, these preferences are serialized in the designer code and thus you will see the same settings you make in the designer. Each time you run you application, the grid will be bound to your design time defined data source, and columns and rows will be initialized with the settings you have done in the designer. In other words, the automatic generation of columns will not override your current settings in the designer.
Therefore you do not need to bother whether AutoGenerateColumns is activated or not. Unless you plan to bind your grid in runtime - as Aldemar does. Then you will have to turn off this option and since you are in runtime, you will also see the property in question. The only thing that you should consider, is setting the correct FieldName values of the columns so that the RadGridView automatically binds them to the datasource you provide.
Considering the behavior described above, I do not see any impediments you might have when not seeing the AutoGenerateColumns property in the property grid of the RadGridView control.
Do not hesitate to write back if you have further questions.
Kind regards,
Deyan
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
In my applications, I bind grid to buisness objects. Thus in design-time, I specify just type of object grid is bound to, not object itself. This has to be set in run-time, after designer code has run.
I think you should try this and see for yourself. Because it really happens and I'm not making this up just for fun.
Cheers,
Daniel
Thanks for writing back.
Indeed, the RadGridView behaves the way you describe it.
However, as we discussed earlier, if you are binding your RadGridView to a data source while in runtime, you will have to explicitly turn off the AutoGenerateColumns functionality if you have already created your columns via the Visual Studio designer.
Please, excuse us for the inconvenience caused.
Kind regards,
Deyan
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.