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

InsertRow MVVM cell binding while editing

1 Answer 14 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Sandra
Top achievements
Rank 1
Sandra asked on 16 Jul 2018, 08:32 PM

I have a GridView bound using MVVM to a collection of `List<Person> People`.

 

Let's say the 'Person' class has properties like:

public List<ID> IDs { get; set; }

public string Name { get; set; }

public DateTime BirthDate { get; set; }

My issue is that I'd like to allow a user to click to insert a new row in the data grid, but I need it so that as they are typing in a 'Name', the DB is doing a query finding all IDs for that person which will populate a ComboBoxColumn for the IDs property above.  So it seems like I need to be able to bind (with MVVM) onto a 'Cell Editing' event for a cell so I can get an event as each character is typed.  I also need to know what item (SelectedItem is null for a new row for some reason in MVVM) is being edited so I can insert the returned array of found IDs into that item.  Any help would be appreciated and I'd like to avoid using Code-Behind.

1 Answer, 1 is accepted

Sort by
0
Dilyan Traykov
Telerik team
answered on 18 Jul 2018, 11:02 AM
Hello Sandra,

I've prepared a small sample project based on the Cascading Combobox Columns demo from our SDK Samples Browser to show a possible implementation of the desired functionality.
 
You can see that I've used an ItemsSourceBinding for the GridViewComboBoxColumn which means that each item will have a different list of countries to choose from. In your case, you should bind this property to each person's IDs collection, and define its getter in such a way that it displays only IDs associated with the current Name of the Person.

I hope this makes sense and helps you in implementing this requirement at your end. If you require any further assistance in the process, please let me know.

Regards,
Dilyan Traykov
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
Sandra
Top achievements
Rank 1
Answers by
Dilyan Traykov
Telerik team
Share this question
or