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

MVVM binding for Grid Selected row

3 Answers 281 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mahesh
Top achievements
Rank 1
Mahesh asked on 27 Feb 2014, 12:44 PM
Hi ,

I have a grid which is binded to list<objects> lets say "List<employee> "

Now I want to have a property in viewmodel like "SelectedEmployee"

How can i bind or configure this?
If i select a row in html page it should fill selected employee?

Thanks,
Mahesh Gupta

3 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 03 Mar 2014, 09:37 AM
Hello Mahesh,

This can be implemented via custom binder for the grid widget.

Here is a sample implementation: http://jsbin.com/jinomela/1/edit

Regards,
Atanas Korchev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Mahesh
Top achievements
Rank 1
answered on 04 Mar 2014, 01:40 PM
Hi Atanas Korchev,

The solution you provided, is it model dependent?
Will the solution work if have multiple grids each having different models binded and not having ID field.

By observing the code snipped, it looks like it uses id field to pick the selected data item..

I require it as generic which does not depend on model.

Thanks,
Mahesh Gupta
0
Atanas Korchev
Telerik team
answered on 04 Mar 2014, 03:03 PM
Hi,

This solution will work as long as the data source has the schema.model.id option set. The id field is required to find the corresponding item. Feel free to modify the code of this binder per your requirements.

Regards,
Atanas Korchev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Mahesh
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Mahesh
Top achievements
Rank 1
Share this question
or