javascript - save handsontable to persistent state -


i have created table using handsontable:

hot = new handsontable(container, {         data: [],         dataschema: {id: null},         startrows: 5,         startcols: 1,         colheaders: ["car"],         columns: [           {data: 'id'}         ],         rowheaders: true,         minsparerows: 1,         persistentstate: true,         onchange: function (change, source) {             console.log(change);             console.log(source);         }       }); 

they have pretty elaborate example on saving/loading to/from server using ajax. however, want use persistent state save load stuff.

in particular want when cell's value in hot changed want save information in local storage, can retrieve later. closest got use change parameter in onchange , save manually localstorage. main question how can save cell's info once changed local storage? better persistentstorage.

also, can save whole hot table local storage? more efficient update whole table every time, or update value of particular cell? there quick way load table? can provide example how can save/load table local storage on change?

eventually, went this:

hot = new handsontable(container, {         data: [],         dataschema: {id: null},         startcols: 4,         colheaders: ["id"],         columns: [           {data: 'id'}         ],         rowheaders: true,         minsparerows: 4,         afterchange: function (change, source) {             // restore table after reload of page             if (source === "loaddata") {                 // load data local storage                 if (localstorage['data']) {                     var data = json.parse(localstorage['data'])                     this.loaddata(data);                     this.render();                     return                 }              }             else {                 // save data local storge if edit happends                 localstorage['data'] = json.stringify(this.getdata());                 return             }         }     }); 

Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -