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

dropdown in a grid

7 Answers 108 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Travis
Top achievements
Rank 1
Travis asked on 23 Aug 2012, 11:48 PM
I'm looking at the the "foreignkey column" demo for the kendoui web grid.  It looks like you can set the "values" property of the column to some data.  My question is can you specify the "text field" and "values field" of the dropdown or does the format of the JSON data have to be "value" and "text"?

demo JSON:
var categories = [{
                    "value": 1,
                    "text": "Beverages"
                },{
                    "value": 2,
                    "text": "Condiments"
                },{

7 Answers, 1 is accepted

Sort by
0
kevin
Top achievements
Rank 1
answered on 27 Aug 2012, 11:59 AM
i have the same question, how can i define the value field and text field? or the JSON response should be a value field and text field
0
Rosen
Telerik team
answered on 28 Aug 2012, 02:44 PM
Hello Travis,

Indeed, it is mandatory for the fields of the items to be named "text' and "value".

Regards,
Rosen
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Stanley
Top achievements
Rank 1
answered on 28 Aug 2012, 03:01 PM
How would you do the same thing with a server side grid binding to an MVC4 model, except that it isn't a foreign key field?
0
Rosen
Telerik team
answered on 29 Aug 2012, 06:21 AM
Hello Stanley,

Could you please elaborate a bit more, as I'm not sure what your exact scenario is?

All the best,
Rosen
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Travis
Top achievements
Rank 1
answered on 30 Aug 2012, 03:06 PM
Is there any easier way to do this then?  Dropdown in a grid seems like a pretty standard scenario.  Can I create a datasource and somehow set the dropdown to use the datasource in the grid?  Do I need to use a template and then set the dropdown's datasource when the row is edited? 
0
Stanley
Top achievements
Rank 1
answered on 30 Aug 2012, 03:13 PM
Suppose I have a dropdown control in a grid.   On some rows I want it loaded with A,B,C  and on other rows I want it loaded with X,Y,Z.  And I want the dropdown colum bound to an MVC4 model that knows when it needs to be loaded with one or the other.   How do I do that?
0
Rosen
Telerik team
answered on 31 Aug 2012, 02:02 PM
Hi guys,

In both scenarios you could use column custom editor. This way you can control the DropDownList widget's DataSource.

Stanley,  I suppose that you are using KendoUI for ASP.NET MVC. In this case you may implement the custom logic as MVC EditorTemplate and assign it to the appropriate field. As you may know Grid widget wrapper is using the MVC framework's built-in EditorTemplates to build its editing UI.

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