Export data from datatable with select element exports each option from the select element

前端 未结 3 1258
遇见更好的自我
遇见更好的自我 2021-01-01 00:40

I am try to add export buttons to my datatable, my table include select boxes inside, the problem is - it export all the options values included in the select box... A am us

3条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-01 01:12

    In case you'll use export format for only visible columns, fixed column indexes will play some tricks on you, so what helped in my case was checking the node child and if it is select, then make the format

    body: function(data, row, col,node) {
       var elementType = node.firstChild;
       if (elementType != null) {
             if (elementType.nodeName == "SELECT") return 
             $(elementType).find(':selected').text();
             else return data;
       }
       else return data
    

提交回复
热议问题