3
votes

so I created a table using Kendo Grid, I create it based on a existing table code:

<table data-role="street-search-results-grid">
        <thead>
        <tr>
            <th data-field="name">Object</th>
            <th data-field="address">Street</th>
            <th data-field="house_no">House nr.</th>
            <th data-field="city">City</th>
        </tr>
        </thead>
    </table>

When I first open this view, I get an empty table which is fine. Then I start searching, and the table fills okay, except table head cells also change their values. So I don't have anymore Object, Street, House nr. and City, but name, address, house_no and city (which are response json keys).

After I get data from server, I update grid's data source by:

       var grid = $(_streetSearchResultsRole).data("kendoGrid");
        grid.setDataSource(new kendo.data.DataSource({
            data: res.data
        }));

Anyone had similar problem?

Tnx :)

1
I could eg. change the keys in JSON from the response, but that isn't an option since my app is multi language (which also I can handle in backend), and I also have some extra js in row template, which has to reckon on same keys of jsonAdrian
Sorry I don't understand what is the actual problem ?Vojtiik

1 Answers

11
votes

The grid will recreate its columns when you use the setDataSource method. You can call the data method of the current data source instead.

grid.dataSource.data(res.data);

Here is a live demo: http://jsbin.com/ACuyoKej/1/edit