16 Answers, 1 is accepted
This should be fairly easy to achieve.
The GridViewDataColumn has two properties : CellTemplate and CellEditTemplate. They respectively control what should be shown in display and edit mode.
So in your case you may put the big and heavy text box in a DataTemplate and set this DataTemplate to the CellEditTemplate property of the column .
For the display mode you may leave the light default TextBox.
In case you have troubles implementing the above described , just let me know.
Greetings,
Pavel Pavlov
the Telerik team
Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>
Thanks Pavel for the prompt response. Is there a way to send me a link to an example that illustrate that? I don’t want the entire row to expand, just maybe a sliding window in below the cell that spans in top of other rows.
Cheers
http://www.telerik.com/help/wpf/radgridview-howto-create-custom-editor.html
Regards
Yes that is the link. As I am not sure what the trouble is . You can just paste me the implementaton of your business object and the property you need edited. I will gather a small runnable sample for you with your object.
All the best,
Pavel Pavlov
the Telerik team
Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>
Thank you for the help. Here is the Cutsome control for the Column that I did based on the color picker exapmle.
Cheers
public class RadTextPopupEditColumn : GridViewBoundColumnBase
{
static RadTextPopupEditColumn()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof (RadTextPopupEditColumn),
new FrameworkPropertyMetadata(typeof (RadTextPopupEditColumn)));
}
public override FrameworkElement CreateCellElement(GridViewCell cell, object dataItem)
{
var cellElement = new StackPanel();
var valueBinding = new Binding(this.DataMemberBinding.Path.Path)
{
Mode = BindingMode.OneTime,
};
var button = new RadButton
{
Content = "...",
Width = 15,
HorizontalAlignment = HorizontalAlignment.Stretch
};
var txtbox = new TextBox
{
Width = 100
};
txtbox.SetBinding(TextBox.TextProperty, valueBinding);
cellElement.Orientation = Orientation.Horizontal;
cellElement.Children.Add(txtbox);
cellElement.Children.Add(button);
return cellElement;
}
public override FrameworkElement CreateCellEditElement(GridViewCell cell, object dataItem)
{
// I tried this code to popup a larger textbox to edit, but it didn't work
var cellEditElement = new TextBox();
this.BindingTarget = TextBox.TextProperty;
cellEditElement.Text = this.Text;
var valueBinding = this.CreateValueBinding();
cellEditElement.SetBinding(TextBox.TextProperty, valueBinding);
cellEditElement.Height = 200;
return cellEditElement;
}
private Binding CreateValueBinding()
{
var valueBinding = new Binding
{
Mode = BindingMode.TwoWay,
NotifyOnValidationError = true,
ValidatesOnExceptions = true,
UpdateSourceTrigger = UpdateSourceTrigger.Explicit,
Path = new PropertyPath(this.DataMemberBinding.Path.Path)
};
return valueBinding;
}
public override void CopyPropertiesFrom(Telerik.Windows.Controls.GridViewColumn source)
{
base.CopyPropertiesFrom(source);
var rmpTextEditorColumn = source as RadTextPopupEditColumn;
if (rmpTextEditorColumn != null)
{
this.Text = rmpTextEditorColumn.Text;
}
}
public static readonly DependencyProperty TextProperty =
DependencyProperty.Register("Text", typeof (string), typeof (RadTextPopupEditColumn),
new PropertyMetadata(default(string)));
public string Text
{
get { return (string) GetValue(TextProperty); }
set { SetValue(TextProperty, value); }
}
}
public class SampleData : INotifyPropertyChanged
{
private string _FirstName;
public string FirstName
{
get { return _FirstName; }
set
{
if (value != _FirstName)
{
_FirstName = value;
OnPropertyChanged("FirstName");
}
}
}
private string _LastName;
public string LastName
{
get { return _LastName; }
set
{
if (value != _LastName)
{
_LastName = value;
OnPropertyChanged("LastName");
}
}
}
private int _Age;
public int Age
{
get { return _Age; }
set
{
if (value != _Age)
{
_Age = value;
OnPropertyChanged("Age");
}
}
}
private Color _FavouriteColor;
public Color FavouriteColor
{
get { return _FavouriteColor; }
set
{
if (value != _FavouriteColor)
{
_FavouriteColor = value;
OnPropertyChanged("FavouriteColor");
}
}
}
private string _Notes;
public string Notes
{
get { return _Notes; }
set
{
if (value != _Notes)
{
_Notes = value;
OnPropertyChanged("Notes");
}
}
}
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
<Window x:Class="TextPopupEditGrid.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
xmlns:TextPopupEditGrid="clr-namespace:TextPopupEditGrid" Title="MainWindow" Height="350" Width="525">
<Grid x:Name="LayoutRoot" Background="White">
<Grid.Resources>
<telerik:ColorToBrushConverter x:Key="colorToBrushConverter" />
</Grid.Resources>
<telerik:RadGridView x:Name="radGridView" AutoGenerateColumns="False" ItemsSource="{Binding}">
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn UniqueName="FirstName" DataMemberBinding="{Binding FirstName}" Header="FirstName" />
<telerik:GridViewDataColumn UniqueName="LastName" DataMemberBinding="{Binding LastName}" Header="LastName" />
<telerik:GridViewDataColumn UniqueName="Age" DataMemberBinding="{Binding Age}" Header="Age" />
<TextPopupEditGrid:RadColorPickerColumn UniqueName="FavouriteColor" DataMemberBinding="{Binding FavouriteColor}"
Header="FavouriteColor" MainPalette="ReallyWebSafe"/>
<TextPopupEditGrid:RadTextPopupEditColumn UniqueName="FavouriteColor" DataMemberBinding="{Binding Notes}"
Header="Notes" />
</telerik:RadGridView.Columns>
</telerik:RadGridView>
</Grid>
</Window>
I am attaching the sample promised.
Regards,
Pavel Pavlov
the Telerik team
Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>
Thumbs up Pavel, that’s what I was looking for :)
Cheers!!!
The link to attached sample "Sample.zip" seems to be dead.
Would you please so kind as to restore it?
This was due to the technical issues we experienced with the attachments and links in our forum threads. However, the problem has been resolved. Can you please try again to download the sample project attached by my colleague?
Best Regards,
Stefan X1
Telerik by Progress
The built in control that we provide for such requirements is the RadMaskedInput. It can be defined within the CellTemplate/CellEditTemplate of the needed column of RadGridView.
Can you please check it out?
Regards,
Stefan X1
Telerik by Progress
Hi Stefan,
I have CellEditTemplate with a Grid containing a TextBox a Button and a Popup. So the Button is only visible when the cell is in edit mode. OnButtonClick opens the Popup and the user can edit the value... this works fine.
But when only double on a cell the cell entering the edit mode but the text is not changeable.
I would have the behavior that the user can change the text in both situations, in edit mode (first step) or via the Popup (secound step).
How to achieve this?
BR, Gert
My best guess for such behavior is that it is related to the binding of the TextBox placed within the CellEditTemplate. From the provided information, however, I cannot confirm this with certainty. May I kindly ask you to provide some additional details on how the element is bound, or provide some code if possible?
Thank you in advance for your cooperation.
Best Regards,
Stefan
Progress Telerik
Our ticketing system restricts the users from being able to delete their posts. Of course, if you do not want to keep your post in this thread, I can delete it for you. Would you like me to do so?
Have a nice weekend, Gert.
Best Regards,
Stefan
Progress Telerik