which rows are selected export those, if not export all

which rows are selected export those, if not export all

RonakRonak Posts: 3Questions: 1Answers: 0
edited August 2016 in Free community support

which rows are selected export those, if not export all

simply want this...

if anybody help i will thankful

PS : Great Plugin

Answers

  • RonakRonak Posts: 3Questions: 1Answers: 0

    @allen
    According you :

    https://datatables.net/forums/discussion/29493/using-select-with-buttons-not-working-correctly

    There is no option for that at the moment..

    and here i found another discussion thread

    According @jLinux :

    https://datatables.net/forums/discussion/30939/export-options-modifier-do-not-export-table-head

    in this discussion below piece of code

    if any rows are selected, then it will only export those selected rows, if no rows are selected, then it will export all rows..

    exportOptions: {
    rows: function ( idx, data, node ) {
    // If rows are selected, export those, if not, export all
    if($dt.rows( { selected: true } ).any())
    return $.inArray(parseInt(data.asset_id), $dt.rows( { selected: true } )) !==-1;
    return true;
    }

    i have tried it. but it didn't work for me if you little bit look into it, it will be helpful...

  • jLinuxjLinux Posts: 981Questions: 73Answers: 75
    edited August 2016

    @Ronak, this example I mocked up for you may be a bit over-kill, but its actually code that I use in production, so it was quicker to go complicated than to code a basic version from scratch :-P

    DT Example

    The buttons on top are multi-level collections, Some of the top level buttons have the row counts in the labels, some are disabled if none are selected. Then once you click those, you see more options, with more labels that are based off of row counts. Then the Export Orders button has a third collection, which allows you to export all rows, the selected rows, or the rows that were filtered.

    Take a looksie at the dtCbsAndEvents.updateOperationButtons object, which will update the button labels based on the class the button has. The callback function is executed anytime any of the numbers would change (so its fired on the events:
    * draw.dt
    * page.dt
    * order.dt
    * draw.dt
    * column-visibility.dt
    * search
    * init.dt
    * deselect.dt
    * select.dt.

    1. To get an idea of the results, you can see here that the Export Orders shows the total rows, and the Perform Action is disabled (Both due to no rows are selected)
    2. Then in this SS, you can see the Perform Action is enabled, and the label was updated to the number of rows selected, just like the Export Orders button went from showing the total rows to the selected rows
    3. Lastly, in this SS, you can see that the nested button collection can show the total rows, selected rows, and visible rows.. (I forgot to add a "filtered" row count button..)

    Hope this helps! There needs to be a little more work done on it, but this should be a good start for you.

  • RonakRonak Posts: 3Questions: 1Answers: 0

    thanks for your reply :)

    it looks promising :)

    i will have to dig into it B)

    you are genius >:)

This discussion has been closed.