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

Bug in GridViewComboBoxColumn?

3 Answers 101 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ryan
Top achievements
Rank 1
Ryan asked on 12 Jul 2010, 09:59 PM
Hello,

I have come across what I believe is a bug in the GridViewComboBoxColumn. The reason for this assumption is that I was able to take a working example of what I was trying to accomplish from this form (see http://www.telerik.com/community/forums/wpf/gridview/displaying-related-table-data.aspx for the attached working version) and reproduce the problem in my environment.

Let me stop to explain what it is I am trying to accomplish. The high level explanation is that I am trying to set the ItemSource property of the GridViewComboBoxColumn to the defaultview of a datatable I am operating on. The behavior is that no values are displayed in the column cells, but editing the column yields a combobox that is properly bound to the datatable.

This behavior can be reproduced with the following steps:

1) Grab the sample project that was provided by Pavel Pavlov of the Telerik team.
2) Convert the project to VS2010.
3) Run the project to make sure it is behaving as it should be.
4) Set the target framework to .NET framework 4.0 Client Profile.
5) Run the project to make sure it is behaving as it should be.
6) Remove all Telerik references.
7) Re-add Telerik references from RadControls for WPF 2010 SP2 (I have a trial license if that makes any difference; version number for assembies is 2010.1.603.35 if that helps).
8) Run the project. You will see that the TownID column is now full of blank cells.

Please let me know if this is a known issue and if/when you expect to be able to release a hotfix. Also, any workarounds you can think of that don't require me to rearchitecht all of my data storage objects would be appreciated.

Quick Start Notes:
    OS: Win XP SP3
    Application Type: WPF
    Target Framework: .Net Framework 4.0 Client Profile
    Language: C#.Net
    IDE: Visual Studio 2010
    Telerik Release Version: Q1 2010 SP2 (Trial License)
    My Telerik Assembly Version: 2010.1.603.35
    Sample (working) Telerik Assembly Version: 2010.1.309.35

Thank You,
Ryan Hansen


3 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 13 Jul 2010, 10:12 AM
Hi Ryan,

In order to make thinks work as expected you will need a small change in the binding syntax as follows:
<telerik:GridViewComboBoxColumn DataMemberBinding="{Binding [TownID]}"

- place the TownID in square brackets. This is needed as we are binding to a DataTable. The requirement is related to the WPF framework.

Now a reasonable question would be - How did it work at first place without the brackets. Well, we had some "clever" code in RadGridView which was later removed as it caused some inconsistencies .

Please excuse us for the inconvenience caused.

As a side note : I wish to say a BIG THANK YOU  for the way you wrote this post. I will keep a bookmark of this thread and will always give it as an example of how a forum post / support ticket should be written .
Providing detailed information with steps to reproduce and platform /product versions greatly decreases the response time and lets us provide a way better support to our customers.
I am updating your Telerik points.

Sincerely yours,
Pavel Pavlov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Ryan
Top achievements
Rank 1
answered on 13 Jul 2010, 05:25 PM
Hello Pavel,

I greatly appreciate your response. I had noticed that Telerik support instructed someone in another post to do just that. I tried to implement that in my code with little success and it never dawned on me to try it in your demo. After making that change in your demo it worked exactly as it is supposed to. However; as I said before, this was not working in my code. I will elaborate on what I mean when I say; "was not working".

I tried to implement your code in my actual application code to no avail. After jostling around with your code I finally came to the realization of what my problem actually was. In my code, I am dynamically creating a cross-tabbed grid using Telerik's rad grid control. Naturally I have a few columns that remain constant, but I also have an n-number of additional columns to add to the grid in code. It is these additional columns that are being created as GridViewComboBoxColumn objects.

What I realized was the culprit in my code is that I was using a numeric ID field to name the columns because it was the only part of the crosstab that could be completely unique to name my columns by. I am not sure if you are aware of this, but the following code will not work:

ds1.Tables[0].Columns.Add(new DataColumn("12", typeof(int)));
GridViewComboBoxColumn newCol = new GridViewComboBoxColumn();
newCol.DataMemberBinding = new Binding("[12]");

Once I came to the conclusion that something inside the RadGridView object was blowing up due to the column name being a number (even if it is cast as a string), I changed my code to this:

ds1.Tables[0].Columns.Add(new DataColumn("C12", typeof(int)));
GridViewComboBoxColumn newCol = new GridViewComboBoxColumn();
newCol.DataMemberBinding = new Binding("[C12]");

While your answer may not have helped me directly; there is a good chance I would have chased my tail for several more hours trying to figure this out. For that I am greatly appreciative. My next question is; is this behavior by design or would it be considered a bug?

Thanks Again,
Ryan Hansen

P.S. I have spent my fair share of time working on the support team as well as in Q/A departments. I understand the difficulties that you all are facing every time you open up one of these posts. Sometimes individuals forget that the the support team; or anyone for that matter, does not put their products through every conceivable implementation that us wacky developers can come up with. I applaud you and your colleagues for the job that you all have undertaken. It isn't an easy one! Oh, and you're welcome!
0
Pavel Pavlov
Telerik team
answered on 19 Jul 2010, 02:44 PM
Hi Ryan,

Please excuse me for the delayed answer.

I believe this can not be considered  a bug in RadGridView.Such behavior is general for WPF .  If you make a test  - bind a regular textblock to a DataRow this way - you will see that the result would be the same . For example the following code will not work :

DataTable dt = new DataTable();
 dt.Columns.Add(new DataColumn("12", typeof(int)));
 dt.Rows.Add(123);
 this.TextBlock1.SetBinding(TextBlock.TextProperty,new Binding("[12]"){ Source = dt.Rows[0]});

*In bindings you can not have properties named with numbers only. Binding using numbers in WPF is reserved for a special case  - when you need to bind to indexers.

Sincerely yours,
Pavel Pavlov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
Ryan
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Ryan
Top achievements
Rank 1
Share this question
or