dimanche 11 juillet 2021

create personaliced filter in datatable with select

i want to create in my datatable one filter personaliced with dropdown but i don´t know where to begin... Sorry it´s my question it´s very bad. I´m reading documentation from datatable reading any forum, and other post from stackoverflow but i don´t know how i can to do.

i need create one filter with this param:

  • new
  • pending
  • null
  • confirm
  • commercialiced
  • confirm-absent
  • confirm-null

i need other dropdown filter but if i do the firts o can to do next.

I need create one select personaliced with this data, and after i need create event and function to controller, etc? i´m working in backend with laravel 5.6. Now i have this code:

initComplete: function () {
            // bottom filter
            this.api().columns([6,8,9]).every( function () {
                var column = this;
                var select = $('<select class="form-control"><option value=""></option></select>')
                    .appendTo( $(column.footer()).empty() )
                    .on( 'change', function () {
                        var val = $(this).val();
                        column.search( this.value ).draw();
                    } );
                
                // If I add extra data in my JSON, how do I access it here besides column.data?
                column.data().unique().sort().each( function ( d, j ) {
                    select.append( '<option value="'+d+'">'+d+'</option>' )
                } );
            } );
        },

but this return actual data en my table and create select. I need create select with x option and after to can search data and fill datatable.

Sorry for my question, and thanks for help me



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire