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

data-columns and binding data

3 Answers 238 Views
MVVM
This is a migrated thread and some comments may be shown as answers.
Felipe Casanova
Top achievements
Rank 1
Felipe Casanova asked on 22 May 2012, 06:07 PM
Is it possible to bind data from a viewmodel to data-columns? I tried the following to no avail.

<div data-role="grid"
                    data-sortable="true" data-editable="true"
                    data-columns="source: myColumns"
                    data-bind="source: entities"
                    data-row-template="rowTemplate"></div>



3 Answers, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 24 May 2012, 03:11 PM
Hello Matt,

This syntax is not supported - the columns should be defined as a JSON string in the data-columns attribute. For example:
data-columns='["ProductName", { "field": "UnitPrice", "format": "{0:c}", "width": "150px" }]'


Kind regards,
Alexander Valchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Mark
Top achievements
Rank 1
answered on 25 Jun 2012, 09:44 PM
Using JSON in the data-columns (as above) works in Firefox, but seems to be broken in IE.  It seems to work for an array of strings, only.

Upon further investigation, it appears to work, but the JSON cannot be split across multiple lines of text... it must all be on the same line, which makes the source rather difficult to read...
0
Cody
Top achievements
Rank 1
answered on 24 Jul 2013, 04:01 PM
I agree. defining the columns in an HTML attribute isn't pleasant. It would be great to be able to do it as a property of the view model.
Tags
MVVM
Asked by
Felipe Casanova
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Mark
Top achievements
Rank 1
Cody
Top achievements
Rank 1
Share this question
or