This is a migrated thread and some comments may be shown as answers.

RadGridView Q3 2008 is repeating or cloning columns data

10 Answers 124 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Aldemar
Top achievements
Rank 1
Aldemar asked on 31 Jan 2009, 04:49 PM
Hi!

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

Sort by
0
Daniel
Top achievements
Rank 1
answered on 01 Feb 2009, 08:17 PM
I have same problem. I have columns defined in design time, then once datasource is assigned in run-time, columns are recreated.

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

 

0
Deyan
Telerik team
answered on 02 Feb 2009, 04:04 PM
Hi Aldemar,

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.
0
Daniel
Top achievements
Rank 1
answered on 02 Feb 2009, 04:49 PM
Does it mean this property didn't work properly until now (2008 Q3 SP2)? Because this behavior changed. I had fix this in about 60 objects (forms) manually.
0
Aldemar
Top achievements
Rank 1
answered on 02 Feb 2009, 08:55 PM
thanks so much!

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
0
Deyan
Telerik team
answered on 03 Feb 2009, 07:02 PM
Hello Daniel,

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.
0
Daniel
Top achievements
Rank 1
answered on 03 Feb 2009, 07:22 PM

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

0
Deyan
Telerik team
answered on 05 Feb 2009, 01:45 PM
Hello 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.
0
Daniel
Top achievements
Rank 1
answered on 06 Feb 2009, 02:01 PM
If AutoGenerateColumns is true and I assign datasource in run-time, design-time set columns remain, but new columns are added at the end of columns collection, copying all properties of assigned data source.

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
0
Deyan
Telerik team
answered on 06 Feb 2009, 07:16 PM
Hi 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.
0
Daniel
Top achievements
Rank 1
answered on 06 Feb 2009, 07:38 PM
That's why it would be very convenient have it available via Property window.
Tags
GridView
Asked by
Aldemar
Top achievements
Rank 1
Answers by
Daniel
Top achievements
Rank 1
Deyan
Telerik team
Aldemar
Top achievements
Rank 1
Share this question
or