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

[Solved] Unable to refresh datasource when initialized with Javascript Array

1 Answer 261 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Preethi
Top achievements
Rank 1
Preethi asked on 10 Feb 2015, 07:00 PM
Hi,

We are building a mobile app and using Angular JS with Kendo UI. We also have a Worklight Adapter to make the Rest call to get JSON Response Data.
The datasource is being initialized in the Angular JS controller, by the response returned from the Adapter call. Something like

    $scope.gridOptions = {
                dataSource: {
                    data: tempData                  
                },
    sortable: false,
                pageable: false,
                columnMenu: true,
                height: "35rem",
                columns: [
                  { field: "CarlineName", title: "Carline Name" },
                  { field: "Today", title: "Today" },
                  { field: "PrevDay", title: "Prev Day"  }                
                ],
               }
            }; 
        };

The issue with this, when the JSON data is refreshed, I see the Adapter returning new data but the grid does not refresh and reflect the new data. Please help !

How can we make the grid refresh too ?

1 Answer, 1 is accepted

Sort by
0
Accepted
Alexander Valchev
Telerik team
answered on 12 Feb 2015, 12:32 PM
Hello Preethi,

The recommended solution for this case is to use dataSource with remote transport that will load the data via Ajax request. In that case in order to refresh the data you should simply call dataSource.read()
In your case the data is not updated because the DataSource creates local copy of the tempData and any subsequent changes of the tempData will not reflect in the DataSource. If you prefer to use this approach you may change the DataSource's data through the data method.

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