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

Confusing behavior of GridViewDataColumn

3 Answers 148 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Tyree
Top achievements
Rank 2
Tyree asked on 02 Aug 2010, 09:09 AM
I haven't be using other column types yet but I find a few things strange/confusing about the behvior of the GridViewDataColumn. I will try to explain them adequately

<telerik:GridViewDataColumn Header="P V" Width="32" UniqueName="PVColumn">
     <telerik:GridViewDataColumn.CellTemplate>
          <DataTemplate>
               <TextBlock Text="something"/>
          </DataTemplate>
     </telerik:GridViewDataColumn.CellTemplate>
</telerik:GridViewDataColumn>
Two weird things about the above. 1) It tries to bind to the UniqueName string on row. 2) I would expect this column to be readonly because no edit template is defined and no datamemberbinding is defined - but instead it shows a blank cell when it goes into edit mode.


<telerik:GridViewDataColumn Header="Colume1" DataMemberBinding="{Binding SomeReadOnlyProperty}" Width="32"
     <telerik:GridViewDataColumn.CellTemplate
          <DataTemplate
               <TextBlock Text="something"/> 
          </DataTemplate
     </telerik:GridViewDataColumn.CellTemplate
     <telerik:GridViewDataColumn.CellEditTemplate
          <DataTemplate
               <TextBox Text="{Binding SomeProperty}"/> 
          </DataTemplate
     </telerik:GridViewDataColumn.CellTemplate
</telerik:GridViewDataColumn>
The above has a DataMemberBinding to a readonly property, this puts the column in a readonly state, even though I have defined a CellEditTemplate and have NOT set IsReadOnly. This seems inconsistent with previous behavior too. I can see how if there is no CellEditTemplate AND the DataMemberBinding is bound to a readonly property that the column IsReadOnly, but not as shown above - i would expect the CellEditTemplate should override anything short or setting IsReadOnly="True".


I just typed these examples so if there are any typo's they are not related to the behaviors mentioned.

3 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 05 Aug 2010, 10:00 AM
Hi Tyree,

When setting CellEditTemplate of a column, you just predefine the default template. Thus in case you do not change it, the primer one will be kept together with all its properties and settings, meaning that the cell will be editable. The fact that no DataMemberBinding is declared signifies that no change of the cell's value will be applied as no property is bound to that value. 
As for the Read-Only property, setting CellEditTemplate will define the way this template behaves, but as the property is read-only, the expected behavior is not to be able to edit it - that is the idea of setting it to read-only. 
You can find more information about different types of columns, their behavior and functionalities in our online documentation.
 

Sincerely yours,
Maya
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
Tyree
Top achievements
Rank 2
answered on 05 Aug 2010, 07:21 PM
Your statement speaks only to "THIS IS HOW IT IS" and not to why it is confusing. Like, what is the point of having an editable column with no property or template to back it? You know it will always be blank.

Lets pretend a super simple example. Lets ignore ways to accomplish similar things.

Our item class has two data properties - FirstName, LastName.

In our grid lets only have one column, and have that colum display Name. Easy enough, we define our own CellTemplate with lets say two TextBlocks. Then a CellEditTemplate with two TextBoxes. Ok, we are done.

But wait, this sweet grid allows for filtering...but I see no filtering icon. Set IsFilterable to true, that should do it. Hmm...nothing. Wait, it has no idea what "data" to filter on but if I set DataMemberBinding it will. I want to avoid ValueConverters so I'll add a readonly property to my item class that formats my Name correctly for display. No reason for a setter, who would use it. Now that I have a Name property I can even get rid of my CellTemplate, sweet. Put that all together, run, bamm! Looks good. I can filter now. Wait, I can't edit the data now. WTH. Lets set IsReadOnly=False; I don't know why it suddenly put itself into ReadOnly mode but if I set the value it will listen to me, right? It still wont go in edit mode. Lets make sure there are no binding errors - nope, all good. Well since the only thing I changed was the DataMemberBinding lets remove it and see. Wow, that makes it work again. Well, it IS bound to a readonly property. Sigh, ok, lets put an empty setter on that property. Ok...that makes it work but empty setters are...pointless and confusing.

DataMemberBinding cannot be assumed to directly relate to whatever is in the CellEditTemplate. If it always did there would be little reason to customize it. CellEditTemplate is the catch-all, "our grid doesn't do that but, here, you can make it". Then by assuming things of DataMemberBinding we lose some of our power. Also I would personally like to see a seperate property to define what the filter is bound to - like FilterMemberPath.

So you assume the column is readonly because DataMemberBinding is bound to a readonly property - and you don't care that there is a CellEditTemplate which isn't bound to the same property (of course it wouldn't be). But then if the column is bound to nothing and has no CellEditTemplate (so therefore is now impossible to edit anything unless you put the input field in the CellTemplate) you don't assume anything. I find this inconsistent.

I love your controls and have used them for years - I mean no offense, just trying to get my point across and hopefully help to improve a great product.

Documentation could definitely be improved. The Silverlight Controls documentation is lacking a lot of basic information. It does contain a lot of examples for sure. Your documentation says you can sort a GridViewColumn but I can find nothing that indicates how. The same with filtering GridViewColumn. Documentation leads you to believe that you can but I can't find enough information to accomplish it.
0
Maya
Telerik team
answered on 10 Aug 2010, 01:39 PM
Hello Tyree,

Thank you for your feedback. We are constantly working on the improvement of our products as well as their online documentation and demos. We would definitely consider your remarks and their implementation.
Furthermore, we have investigated the case with the definition of a CellEditTemplate while a binding to a ReadOnly property is performed. Indeed, it may be better to allow both a ReadOnly property and edit-mode when such template is defined. The issue will be fixed as soon as possible. 
As for the filtering, so far there is no possibility to filter unless DataMemberBinding is defined. 
In case you have any further insides and suggestions on how to improve our products and support, we would appreciate your feedback.
 

Kind regards,
Maya
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
Tyree
Top achievements
Rank 2
Answers by
Maya
Telerik team
Tyree
Top achievements
Rank 2
Share this question
or