Sorting on unique link text

Sorting on unique link text

ronr1999ronr1999 Posts: 1Questions: 1Answers: 0
edited October 2018 in Free community support

I'm doing:

        this.api().columns([1]).every( function () {
            var column = this;
            var select = $('<select><option value="">Brands</option></select>')
            .appendTo( $(column.header()).empty() )
            .on( 'change', function () {
                var val = $.fn.dataTable.util.escapeRegex(

                .search( val ? '^'+val+'$' : '', true, true )
            } );

   function ( d, j ) {
                // "d" IS A LINK, GET THE TEXT ONLY
                d = $(d).text();
                select.append( '<option value="'+d+'">'+d+'</option>' )
            } );
        } );

But... I want unique.sort on just the .text of the link. Can I give unique() options to use only the text?

Thanks! I'm fairly new to this...


  • colincolin Posts: 3,370Questions: 0Answers: 600

    Hi @ronr1999 ,

    Yep, you can add anything into that select list. You would want to parse the string to get just the text on line 17, then you may also need to modify what you search for (if you need to reconstruct the original string) on line 10.



Sign In or Register to comment.