i have cells in handsontable, displayed using "html" renderer. when copy these cells , paste them in excel, html content instead of data. there way display cells are, , value when copying ?
jsfiddle example: example
document.addeventlistener("domcontentloaded", function() { var data = [ { title: "title 1", description: "<div style='text-align:right'>148</div>" }, { title: "title 2", description: "<div style='text-align:right'>2002</div>" } ], container1, hot1; container1 = document.getelementbyid('example1'); hot1 = new handsontable(container1, { data: data, colwidths: [200, 200], colheaders: ["title", "description"], columns: [ {data: "title", renderer: "html"}, {data: "description", renderer: "html"} ] }); });
you can try converting input data json format , have custom renderer displays value json. add tostring property data return want copied.
here updated fiddle: http://jsfiddle.net/mpusarla/gng4wqzy/6/
document.addeventlistener("domcontentloaded", function() { var item1 = {}; item1.title = "title 1 "; item1.description = {}; item1.description.text = "desc 1"; item1.description.tostring = function() { return 'updated desc 1'; } var item2 = {}; item2.title = "title 2"; item2.description = {}; item2.description.text = "desc 2"; item2.description.tostring = function() { return 'updated desc 2 '; } var data = []; data.push(item1); data.push(item2); var container1, hot1; function customrenderer(instance, td, row, col, prop, value, cellproperties) { td.innerhtml = '<div style="text-align:right">' + value.text; } container1 = document.getelementbyid('example1'); hot1 = new handsontable(container1, { data: data, colwidths: [200, 200], colheaders: ["title", "description"], columns: [{ data: "title", renderer: "text" }, { data: "description", renderer: customrenderer }] }); }); </style><!-- ugly hack due jsfiddle issue --> <script src="http://docs.handsontable.com/0.15.0/scripts/jquery.min.js"></script> <script src="http://docs.handsontable.com/0.15.0/bower_components/handsontable/dist/handsontable.full.js"></script> <link type="text/css" rel="stylesheet" href="http://docs.handsontable.com/0.15.0/bower_components/handsontable/dist/handsontable.full.min.css"> <div id="example1" class="hot handsontable"></div>
Comments
Post a Comment