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

Custom Cell editor

16 Answers 437 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Perlom
Top achievements
Rank 1
Perlom asked on 24 Aug 2011, 01:45 PM
Hi,
We need to have a RadGridView containing a bound column that could hold a long text (up 4000 char). Each cell if the column will have a little button on the side, and would just show a portion of the text. When the user clicks on the button, an editor popups (ideally in adjacent to the clicked cell) and user can edit the entire text and save it back to cell. Is that doable with the RdaGrdiView? Any help would be much appreciated.
Thanks

16 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 24 Aug 2011, 03:09 PM
Hi Perlom,

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 >>

0
Perlom
Top achievements
Rank 1
answered on 24 Aug 2011, 04:33 PM

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

0
Perlom
Top achievements
Rank 1
answered on 24 Aug 2011, 09:42 PM
I have found this sample in another thread here. It exactly does what I want but with the color picker instead.  I have been trying to use the same way but with a textbox, but no avail all day!!! any idea how should I go about this?? Here is the link:

http://www.telerik.com/help/wpf/radgridview-howto-create-custom-editor.html


Regards
0
Pavel Pavlov
Telerik team
answered on 25 Aug 2011, 10:14 AM
Hi Perlom,

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 >>

0
Perlom
Top achievements
Rank 1
answered on 25 Aug 2011, 06:01 PM
Hi Pavel,

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>

0
Perlom
Top achievements
Rank 1
answered on 27 Aug 2011, 05:15 PM
If this seems to be too hard, anybody has any other sugestion to achieve the same result?
0
Pavel Pavlov
Telerik team
answered on 31 Aug 2011, 03:10 PM
Hello Perlom,

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 >>

0
Perlom
Top achievements
Rank 1
answered on 31 Aug 2011, 05:06 PM

Thumbs up Pavel, that’s what I was looking for :)

 

Cheers!!!

0
Franz
Top achievements
Rank 1
answered on 12 Oct 2016, 03:41 PM

The link to attached sample "Sample.zip" seems to be dead.

Would you please so kind as to restore it?

0
Stefan
Telerik team
answered on 17 Oct 2016, 11:39 AM
Hello Franz,

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
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Praveen
Top achievements
Rank 1
answered on 15 Dec 2016, 06:29 AM

Hi 

how to implement list of comma separated id's with hyperlink in rad grid single column. 

please help me.

0
Stefan
Telerik team
answered on 19 Dec 2016, 11:22 AM
Hi Praveen,

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
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Gert
Top achievements
Rank 1
answered on 17 Nov 2017, 12:48 PM

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

 

0
Stefan
Telerik team
answered on 22 Nov 2017, 11:33 AM
Hi 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
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Gert
Top achievements
Rank 1
answered on 22 Nov 2017, 12:24 PM
Hi Stefan, thanks a lot for your replay. Yes it was a binding problem and I solved it in the mean time. Btw how can I delete my own post if it become obsolete? BR, Gert
0
Stefan
Telerik team
answered on 24 Nov 2017, 12:01 PM
Hello Gert,

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
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Tags
GridView
Asked by
Perlom
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Perlom
Top achievements
Rank 1
Franz
Top achievements
Rank 1
Stefan
Telerik team
Praveen
Top achievements
Rank 1
Gert
Top achievements
Rank 1
Share this question
or