how to use dolly.js over already define html table for functionality of excel like drag and copy the cell of table

◇◆丶佛笑我妖孽 提交于 2019-12-08 11:29:46

问题


see this js fiddle[http://jsfiddle.net/pUAXd/17/] i am creating my table in html body and want to use drag and copy functionality of dooly.js over my table like the 2nd table..


回答1:


You just need to grab the data from the table before the rederizartion and then use this data to create the table with dolly.js

tableController.element = $("table");
tableController.data = [];
tableController.element.find('tr').each(function(i, line) {
    var lineData = [];
    $(line).find('td').each(function(j, cell) {
        lineData.push($(cell).html());
    });
    tableController.data.push(lineData);
});
tableController.render();

I've updated the fiddle for you: http://jsfiddle.net/pUAXd/66/

I hope it helps.



来源:https://stackoverflow.com/questions/21902079/how-to-use-dolly-js-over-already-define-html-table-for-functionality-of-excel-li

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!