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

[Solved] Getting LostFocus/TextChange event of GridViewDataColumn when moved to DataTemplateColumn

3 Answers 375 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
veena
Top achievements
Rank 1
veena asked on 04 Dec 2009, 02:42 PM

Hi,


We have a xaml in which we are using a radgridview.It has 3 columns.
1) 1st column is an emailaddresscolumn
2) 2nd column is the username column
3) 3rd column is the usertype column

XAML tags of the RadGridView and the columns.
<telerikGrid:RadGridView x:Name="rgvUsers"
 ItemsSource="{Binding Users,Mode=TwoWay}">

 <telerikGrid:GridViewDataColumn HeaderText="Email Address"                                                       
                                                        UniqueName="EmailAddress" DataMemberBinding="{Binding EmailAddress, Mode=TwoWay}">
                            <telerikGrid:GridViewDataColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBlock x:Name="txtValue" Text="{Binding EmailAddress, Mode=TwoWay}">
                                
                                        </TextBlock>
                                </DataTemplate>
                            </telerikGrid:GridViewDataColumn.CellTemplate>
                           
                        </telerikGrid:GridViewDataColumn>
                        <telerikGrid:GridViewDataColumn HeaderText="Alias"
                                                        DataMemberBinding="{Binding Alias, Mode=TwoWay}"
                                                        UniqueName="Alias"></telerikGrid:GridViewDataColumn>

  <telerikGrid:GridViewDataColumn HeaderText="UserType"
                                                        DataMemberBinding="{Binding UserTypes, Mode=TwoWay}"
                                                        UniqueName="UserType">
                            <telerikGrid:GridViewDataColumn.CellTemplate>
                                <DataTemplate>
                                    <ComboBox x:Name="comboBoxusertype"
                                              ItemsSource="{Binding UserTypes, Mode=TwoWay}"
                                              DisplayMemberPath="Name"
                                              SelectedItem="{Binding SelectedType, Mode=TwoWay}"                                               
                                              >
                                      
                                    </ComboBox>
                                </DataTemplate>
                            </telerikGrid:GridViewDataColumn.CellTemplate>
                            <telerikGrid:GridViewDataColumn.CellEditTemplate>
                                <DataTemplate>
</Grid>

Here we face an issue  like this.

Requirement:
When we enter emailaddress for a user and navigate to either 2nd or 3rd column, the alias name should automatically get updated with the username(taken from the emailaddress. eg; test@gmail.com; username will be 'test'). This occurs when we navigate from emailaddress gridviewdatacolumn to next column using tab key.
Issue
But after entering the emailaddress if we directly choose the combobox and click/choose any user, the lostfocus of the emailaddress gridviewdatacolumn is not firing and we are not able to get the alias name displayed. This is occuring when we gave the 3rd column as :

We tried to change the 3rd column from GridViewDataColumn to GridViewcomboboxcolumn. Then we are able to get the lost focus of the emailaddress datacolumn and the alias name is getting displayed.But when we gave the 3rd column as GridViewcomboboxcolumn, the items are not getting populated in the combobox.
Note
The UserType which is a property inside the Users property  is an observablecollection of UserTypeclass which has some properties like name,id and all.

 
Please help us to get the alias name updated when we navigate from 1st column to 3rd column

Thanks in advance

VR

3 Answers, 1 is accepted

Sort by
0
Tsvyatko
Telerik team
answered on 09 Dec 2009, 05:45 PM
Hi veena,

Based on the code fragment you sent me I have build application that demonstrates how to solve your issues:

 - Using CellEditEnded to to track the edit of the email field

- Implement INotifyChanged for User class

In addition the project illustrates how to display the UserType column using GridViewComboBoxColumn.

If the project does not clerify the solution or you have any more questions do not hesitate to contact us.

All the best,
Tsvyatko Konov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
veena
Top achievements
Rank 1
answered on 10 Dec 2009, 02:44 PM
Hi,

thanks for the reply,
But we dont want to add columns from code behind. We have put the tags for the columns in the xaml. We are using MVVM pattern of implementation. So the Users, UserType all resides in the ViewModel wirtten for the class.

Please help in this.

Thanks in advance
VR
0
Tsvyatko
Telerik team
answered on 16 Dec 2009, 09:49 AM
Hi veena,

 In your case there are two options:

 - Create IValueConverter over nickname column that extracts the information from email and make the column read-only

 - Since this is logic related to the data rather to the formatting - add logic to your data object synchronizing the data in the desired way. E.g.
public string EmailAddress
{
    get { return emailAddress; }
    set
    {
        emailAddress = value;
        OnPropertyChanged("EmailAddress");
        Alias = emailAddress.Substring(0, emailAddress.IndexOf('@'));
    }
}

Hope this helps.

All the best,
Tsvyatko
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
GridView
Asked by
veena
Top achievements
Rank 1
Answers by
Tsvyatko
Telerik team
veena
Top achievements
Rank 1
Share this question
or