data-columns and binding data

4 posts, 0 answers
  1. Felipe Casanova
    Felipe Casanova avatar
    56 posts
    Member since:
    Feb 2010

    Posted 22 May 2012 Link to this post

    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"

  2. Alexander Valchev
    Alexander Valchev avatar
    2895 posts

    Posted 24 May 2012 Link to this post

    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!
  3. Mark
    Mark avatar
    1 posts
    Member since:
    Mar 2012

    Posted 25 Jun 2012 Link to this post

    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...
  4. Cody
    Cody avatar
    12 posts
    Member since:
    May 2013

    Posted 24 Jul 2013 Link to this post

    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.
Back to Top