Okay
  Public Ticket #2070817
Multi-Sorting by default
Closed

Comments

  •  1
    DSWerbeagentur started the conversation

    Hello there,

    i need a quick fingertip: How can i customize the script to use a secondary sorting coloumn (asc/desc) on page load, without manually trigger the SHIFT-Key on Keyboard?

    I hope you could help me our, because i got a table, sorted by the 1. coloumn and need to sort these values from the start by the 2. cloumn afterwards (multi-sort).

    Thanks in advance,
    Ben

  •  2,498
    Aleksandar replied

    Hello Ben.

    I am sorry to disappoint you, but unfortunately anything other than holding SHIFT key would be done through some custom work, which is not covered in the included support of the plugin.

    I can point you to our hooks and filters, so you can take a look if there's anything there that could help you out, but that's as much as I can do about this.

    Best regards.

    Kind Regards, 

    Aleksandar Vuković
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables

  •  1
    DSWerbeagentur replied

    Hello there,

    i think there should be an option to change the default behaviour of a feature, that is already implemented, but no problem because i build a workaround and want to share this with the community:

    To trigger an SHIFT+Click Event on a specific row, just add a custom CSS Class to the coloumn via the backend (for example "dummy_coloumn") and afterwards add the following code to the site where you use the DataTable (or add this under Settings->Custom JS/CSS):

    jQuery(window).load(function(){
      wpDataTables.table_1.init(
      function(){
        
        var shiftClick = jQuery.Event("click");
        shiftClick.shiftKey = true;
        jQuery(".dummy_coloumn").trigger(shiftClick);
       })
    });

    This performs an automatic click on the header of that coloumn and sorts it the way it would if you click with holding down SHIFT.

    Notice: My table is called "table_1" and perhaps needs to be changed in your project.
    Notice: Perhaps you need an other kind of sorting (asc / desc), so just add another line of

    jQuery(".dummy_coloumn").trigger(shiftClick);

    and this will do the job.


    It works perfectly for me, perhaps i can help someone out who is looking for this kind of function.


    Best wishes from Germany,
    Ben

  •  2,498
    Aleksandar replied

    Hey Ben.

    Thank you very much for your feedback! I'm sure it will be of use to our customers, as well as myself.

    We are constantly working on improving the plugin, and we'll try to implement the feature behavior change if at all possible. I'll forward it to our development team, so they can take a look.

    Best regards.

    Kind Regards, 

    Aleksandar Vuković
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables