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

HTML 5 local storage as backend

4 Answers 273 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Timo
Top achievements
Rank 1
Timo asked on 13 Jan 2012, 02:46 PM
Hi.

Is it possible to use HTML 5 local storage as a backend of the Kendo UI datasource? I couldn't find any examples on how to do this.

If it isn't possible, is this considered in the roadmap?

Br,
Timo Westkämper

4 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 13 Jan 2012, 03:54 PM
Hi,

 Yes it is possible to use local storage as a backend of the Kendo UI data source. It is easy to implement this by creating a custom transport:

dataSource: {
     transport: {
            read: function(options) {
                  var data = readDataFromLocalStorage();
                  options.success(data);
            }
     }
}

Regards,
Atanas Korchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Timo
Top achievements
Rank 1
answered on 13 Jan 2012, 03:58 PM
Hi Atanas. Thanks for your fast reply. Is it possible to also update the local storage?

Does the Datasource abstraction also support fetch by id?

Timo
0
Atanas Korchev
Telerik team
answered on 13 Jan 2012, 04:02 PM
Hi,

 Yes, it is possible:

dataSource: {
     transport: {
            read: function(options) {
                  var data = readDataFromLocalStorage();
                  options.success(data);
            },
            update: function(options) {
                   updateDataToLocalStorage(options);
            }
     }


The datasource does not support fetch by id. The read method will read a page of data or all data if paging is not enabled.

All the best,
Atanas Korchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
raj
Top achievements
Rank 1
answered on 03 Feb 2012, 09:50 AM
Hi
      I followed the below method

  datasource = new kendo.data.DataSource({
                    transport:
                {
                    read: function (options) {
                        var data = orders;
                        options.success(data);
                    }
                }

                });

when i assigned this datasource to my grid..My grid was empty... But I have datas in orders.....


I also tried like this to check fetching datas ffrom offline but in vain
 $.ajax({
                url: url,
                data: data,
                type: 'POST',
                contentType: 'application/json',
                dataType: 'json',
                success: function (result) {
                    var data = result;
                        options.success(data); 
                          datasource = new kendo.data.DataSource({
                    transport:
                {
                    read: function (options) {
                        var data = result;
                        options.success(data);
                    }
                }

                });



  
                            $("#grid").kendoGrid({
                    dataSource: {
                        data: datasource

                    },
                    height: 360,
                    groupable: false,
                    scrollable: false,
                    sortable: false,
                    pageable: false,
                    columns: [{
                        field: "ContactID",

                        title: "First Name"
                    }]
                });


                }
            });


Please help
Tags
Data Source
Asked by
Timo
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Timo
Top achievements
Rank 1
raj
Top achievements
Rank 1
Share this question
or