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

Excel-like edit textbox

8 Answers 151 Views
GridView
This is a migrated thread and some comments may be shown as answers.
juergen
Top achievements
Rank 1
juergen asked on 06 Sep 2010, 08:00 AM
Hi,

  • i have to bind a Textbox to a current cell.value (Excel-like Editbox behavior, if you type into  a gridcell the typed char appears directly in the Textbox and vice-versa).

  • UpdateSourceTrigger=PropertyChanged seems not to work with a gridcell.

  • Text="{Binding ElementName=RadGridView1, Path=CurrentCell.Value} doesn't work ?

regards,
Juergen

8 Answers, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 06 Sep 2010, 08:42 AM
Hi juergen,

Does your business object implements the INotifyPropertyChanged interface?
Please check our online demo about datasource change notifications.

Greetings,
Veselin Vasilev
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
juergen
Top achievements
Rank 1
answered on 06 Sep 2010, 09:15 AM
Hello Veselin,

1.) yes, my viewmodel implements INotifyPropertyChanged.

2.) your example is not  excactly the wanted behavior, because typed in chars appears on LostFocus of the cell/Textbox and
not as needed simultaneously like in Excel.

Sorry, I didn't found this similar behavior on your examples.

regards,
Juergen

0
Accepted
Veselin Vasilev
Telerik team
answered on 06 Sep 2010, 04:37 PM
Hi juergen,

I managed to implement what you want only from the textbox to the cell, e.g. typing in the textbox updates the underlying property immediately. To make it the other way around - you need to redefine the CellEditTemplate.

Find attached a sample project.

Sincerely yours,
Veselin Vasilev
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
juergen
Top achievements
Rank 1
answered on 12 Sep 2010, 10:14 AM
Hello Veselin,

thank you for your proposal.

Your example is using a preconfigured xaml-declaration of the datatemplate:

    <Window.Resources>
        <DataTemplate x:Name="SyncToBoxTemplate" x:Key="SyncToBoxTemplate">
            <TextBox Text="{Binding UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" />
        </DataTemplate>
    </Window.Resources>

But in my case i have to use a dynamic datacolumn creation:

                private void AddGridViewDataColumn(string uniqueName)
{
GridViewDataColumn column = new GridViewDataColumn();
column.UniqueName = uniqueName;
column.Header = uniqueName;     // LocalizationManager.GetString(uniqueName);

Binding bind = new Binding(uniqueName);
bind.Mode = BindingMode.TwoWay;
bind.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;

column.DataMemberBinding = bind;
column.CellTemplate = (DataTemplate)FindResource("SyncToBoxTemplate");

grdView.Columns.Add(column);
Debug.WriteLine("Column: " + uniqueName + " added."); 
}

The gridviewcolumn is created, only the Textboxoutline in the cell is drawn, but with no content.

Changing the celltemplate to textblock:
    <Window.Resources>
        <DataTemplate x:Name="SyncToBoxTemplate" x:Key="SyncToBoxTemplate">
            <!--<TextBox Text="{Binding Name, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" />-->
            <TextBlock></TextBlock>
        </DataTemplate>
    </Window.Resources>

Content of MyViewModel is there (visible in editmode), also with desired effect, but not visible.
What I'm doing wrong?

regards,
Juergen









0
Veselin Vasilev
Telerik team
answered on 14 Sep 2010, 08:41 AM
Hi juergen,

Do you set the Path of the Binding of the TextBox when a cell is selected as I do in my test project?


Regards,
Veselin Vasilev
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
juergen
Top achievements
Rank 1
answered on 14 Sep 2010, 01:47 PM
Hi Veselin,

this part is also active:
                private void grdView_SelectedCellsChanged(object sender, GridViewSelectedCellsChangedEventArgs e)
{
GridViewCellInfo ci = e.AddedCells[0];
Binding b = new Binding((ci.Column as GridViewDataColumn).DataMemberBinding.Path.Path)
{
Mode = BindingMode.TwoWay,
UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged,
Source = ci.Item
};
txtContent.SetBinding(TextBox.TextProperty, b);
}
There's a kind of switching bind, on creation of the column and when SelectCellsChanged-event is raised.
But I don't see how to resolve this.




Thank you for your help.

regards,
Juergen
0
Veselin Vasilev
Telerik team
answered on 14 Sep 2010, 01:51 PM
Hello juergen,

I am not sure what went wrong in this case. Can you please prepare a sample project (or just modify the one I sent you) which demonstrates the problem? You have to attach it in a new support ticket as a zip archive.

Thanks

All the best,
Veselin Vasilev
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
juergen
Top achievements
Rank 1
answered on 14 Sep 2010, 02:21 PM
Ok, I'll do so.
Tags
GridView
Asked by
juergen
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
juergen
Top achievements
Rank 1
Share this question
or