Passing an array generated from datatable to server side!

Passing an array generated from datatable to server side!

vinitsharmavinitsharma Posts: 23Questions: 0Answers: 0
edited August 2012 in General
Hello all,
As I am not able to format the Excel exported file from datatable, so I am generating the excel file through some other means. In my vb code, I am calling a function which generates the excel file according to the dataset passed in it. My question here is that, is there some method of datatables through which I can send an array generated in javascript to the server side code i.e. vb code? In my javascript function I am storing the name of the currently visible columns inside an array, so is there some AJAX based method of datatables through which I can send this array to vb code i.e. server side? Also how can I access the current page data of datatables i.e. suppose my datatable currently shows 10 records of the first page with few columns hidden or not hidden. So can I access this data from datatable by any particular method ? Please help. All suggestions welcomed. Thanx.!

Replies

  • vinitsharmavinitsharma Posts: 23Questions: 0Answers: 0
    I did got a solution for getting the current datatables data like the current page data and that too excluding the hidden columns data through this.fnGetTableData(oConfig). But this data is in the form of a large string. How can I get this data in some particular array elements separated manner or in a manner through which i can saggregate each particular cells data of the datatable? Please tell.
  • allanallan Posts: 63,161Questions: 1Answers: 10,406 Site admin
    > is there some method of datatables through which I can send an array generated in javascript to the server side code i.e. vb code?

    Use fnGetData and then a jQuery Ajax request with the data.

    Allan
  • vinitsharmavinitsharma Posts: 23Questions: 0Answers: 0
    Many thanx for your reply Allan. I need to trigger the click event of the Export to Excel button. In the aButtons[] array where I have defined the two buttons for 'Excel' and 'PDF', I tried removing the code(function) written inside the "fnClick": property of datatable and posted my own code inside it. But still my code isnt showing any effect while undoing and pasting the old code does gets executed. So how can I catch the click event of the Export To Excel button? I did tried this with jQuery click() event but that didn't worked too. So is there any way of catching the click event of the "Export To Excel" button. Do I need to remove some properties defined with this button ? Kindly tell.
  • allanallan Posts: 63,161Questions: 1Answers: 10,406 Site admin
    Using fnClick should do:

    [code]
    oTableTools: {
    aButtons: [
    {
    sExtends: "text",
    fnClick: function ( button, conf ) {
    var data = datatable.fnGetData();
    // ...
    }
    ]
    }
    [/code]
This discussion has been closed.