This question is locked. New answers and comments are not allowed.
Hi:
I have a RadGridView that lists properties. The names of the properties are in column 1 and the values of the properties are in column 2.
Most of the property values are text and can be edited in the normal way, but a few of them require a selection via a RadComboBox. How can I position a RadComboBox over the cell in the BeginningEdit event?
Thanks,
Terry
I have a RadGridView that lists properties. The names of the properties are in column 1 and the values of the properties are in column 2.
Most of the property values are text and can be edited in the normal way, but a few of them require a selection via a RadComboBox. How can I position a RadComboBox over the cell in the BeginningEdit event?
Thanks,
Terry
8 Answers, 1 is accepted
0
Hi Terry,
Maya
the Telerik team
You may take a look at this forum thread for a reference and a sample project.
Maya
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
Terry
Top achievements
Rank 1
answered on 11 Jan 2011, 07:47 PM
Thanks, Maya, this works great as far as it goes. One issue, though is setting the combobox to the current underlying PropertyValue when the edit starts.
Thanks,
Terry
Thanks,
Terry
0
Terry
Top achievements
Rank 1
answered on 15 Jan 2011, 08:38 PM
As I have received no response to this, I might need to clarify.
Using the SL_RadGridView_Template sample code, the initial selected value is 1. When I click on the cell and enter edit mode, the combobox has no selected value. it should be initialized to 1.
Also if I select one of the choices, this is correctly reflected in the underlying textblock, but when I go back and edit a second time, I am given a combobox with no item selected again. It should be initialized to the underlying current value.
How do I accomplish this? Even though the binding mode is two way, it looks like the binding is only working one way.
Thanks,
Terry
Using the SL_RadGridView_Template sample code, the initial selected value is 1. When I click on the cell and enter edit mode, the combobox has no selected value. it should be initialized to 1.
Also if I select one of the choices, this is correctly reflected in the underlying textblock, but when I go back and edit a second time, I am given a combobox with no item selected again. It should be initialized to the underlying current value.
How do I accomplish this? Even though the binding mode is two way, it looks like the binding is only working one way.
Thanks,
Terry
0
Hi Terry,
Greetings,
Maya
the Telerik team
You may try to use a RadComboBox instead of a regular ComboBox:
<DataTemplate x:Key="EnumPropertyValueEditTemplate"> <telerik:RadComboBox SelectedValue="{Binding PropertyValue, Mode=TwoWay}" ItemsSource="{Binding EnumNames}" /></DataTemplate>Greetings,
Maya
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
Terry
Top achievements
Rank 1
answered on 25 Jan 2011, 08:06 PM
That solves the initialization problem.
Thanks for your help, Maya!
Thanks for your help, Maya!
0
Terry
Top achievements
Rank 1
answered on 08 Feb 2011, 03:56 AM
It turns out this technique is causing another problem for me. Previously, I was using the grid's BeginningEdit event to determine whether the cell was editable and the CellValidating event to validate the results and store them away. After adding a template selector, this still works for cells where I use the enumerator with a RadComboBox, but it does not work for the non-enumeration cells which use a TextBox for editing. I'm uncertain how I can hook in events for text cells to allow/disallow editing and for validating and saving results after the edit.
Stated another way, cell events ARE NOT working when a textbox template is selected, but they ARE working when a RadComboBox enumerator is selected.
Can you help me with this?
Thanks,
Terry
Here's the grid XAML:
and here's the template XAML:
and here's the C#:
Stated another way, cell events ARE NOT working when a textbox template is selected, but they ARE working when a RadComboBox enumerator is selected.
Can you help me with this?
Thanks,
Terry
Here's the grid XAML:
<radGridView:RadGridView x:Name="gvProperties" VerticalAlignment="Stretch" AutoGenerateColumns="False" ScrollViewer.HorizontalScrollBarVisibility="Auto" ShowColumnHeaders="False" SelectionMode="Single" CanUserSelect="True" GridLinesVisibility="Both" ShowGroupPanel="False" ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollMode="Deferred" RowIndicatorVisibility="Collapsed" CanUserDeleteRows="False" CanUserInsertRows="False" RowLoaded="gvProperties_RowLoaded" BeginningEdit="gvProperties_BeginningEdit" CellEditEnded="gvProperties_CellEditEnded" SelectionChanged="gvProperties_SelectionChanged" CellValidating="gvProperties_CellValidating" > <radGridView:RadGridView.Columns> <radGridView:GridViewDataColumn UniqueName="PropAlias" Width="1*"/> <radGridView:GridViewDataColumn UniqueName="PropValue" Width="1*" CellTemplateSelector="{StaticResource PropertyValueTemplateSelector}" CellEditTemplateSelector="{StaticResource PropertyValueEditTemplateSelector}" /> </radGridView:RadGridView.Columns> </radGridView:RadGridView> and here's the template XAML:
<DataTemplate x:Key="TextPropertyValueEditTemplate"> <TextBox Text="{Binding PropValue, Mode=TwoWay}"/> </DataTemplate> <DataTemplate x:Key="TextPropertyValueDisplayTemplate"> <TextBlock Text="{Binding PropValue}" /> </DataTemplate> <DataTemplate x:Key="EnumPropertyValueEditTemplate"> <radinput:RadComboBox SelectedValue="{Binding PropValue, Mode=TwoWay}" ItemsSource="{Binding EnumNames}" /> </DataTemplate> <local:PropertyValueDataTemplateSelector x:Key="PropertyValueEditTemplateSelector" TextTemplate="{StaticResource TextPropertyValueEditTemplate}" EnumTemplate="{StaticResource EnumPropertyValueEditTemplate}" /> <local:PropertyValueDataTemplateSelector x:Key="PropertyValueTemplateSelector" TextTemplate="{StaticResource TextPropertyValueEditTemplate}" EnumTemplate="{StaticResource TextPropertyValueDisplayTemplate}"/> and here's the C#:
using System.Windows; using Telerik.Windows.Controls; namespace WireframeEditor { public class PropertyValueDataTemplateSelector : DataTemplateSelector { public override System.Windows.DataTemplate SelectTemplate(object item, System.Windows.DependencyObject container) { if ( ( (MainPage.ElementProperty) item ).PropName == "Type" ) { return this.EnumTemplate; } else { return this.TextTemplate; } } public DataTemplate TextTemplate { get; set; } public DataTemplate EnumTemplate { get; set; } } }0
Hi Terry,
All the best,
Maya
the Telerik team
You need to make a slight change to the definition of the PropertyValueTemplateSelector:
<local:PropertyValueDataTemplateSelector x:Key="PropertyValueTemplateSelector" TextTemplate="{StaticResource TextPropertyValueDisplayTemplate}" EnumTemplate="{StaticResource TextPropertyValueDisplayTemplate}"/>Maya
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
Terry
Top achievements
Rank 1
answered on 08 Feb 2011, 10:12 PM
With your change, everything is working perfectly.
Thanks for your quick response!
Terry
Thanks for your quick response!
Terry