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

Grid using data-attribute initialization

1 Answer 291 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 18 Jul 2013, 08:11 PM
I'm having trouble using data-attribute initialization for the grid.

I created a jsbin using the KendoUI web sample code, with "dataSource", "columns", and "pageable" moved to global var's.
http://jsbin.com/uwicus/1/

As you can see in the jsbin, the grid works correctly when initialized by

<script>
    $(document).ready(function() {
        $("#grid").kendoGrid({
            dataSource: ds,
            height: 430,
            scrollable: true,
            sortable: true,
            filterable: true,
            pageable: pageableProperties,
            columns: columnList
        });
    });
</script>
However, when I switch to the equivalent data-attribute initialization, it no longer works correctly
<div
    id="grid"
    data-role="grid"
    data-source="ds"
    data-height="430"
    data-scrollable="true"
    data-sortable="true"
    data-filterable="true"
    data-pageable="pageableProperties"
    data-columns="columnList"
/>

Please let me know what I'm missing here.  Thx.

1 Answer, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 19 Jul 2013, 11:06 AM
Hi Robert,

In order to trigger the declarative initialization, you should use kendo.init or kendo.bind

In addition, the data-columns/data-pageable attributes cannot accept variable names. They should contain the configuration options itself. For example:
data-columns='["ProductName", { "field": "UnitPrice", "title": "Unit Price", "format": "{0:c}", "width": "130px" }]'

I hope this will help.

Regards,
Alexander Valchev
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
Robert
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Share this question
or