Row_Details and Multi_Filter_Select

Row_Details and Multi_Filter_Select

ilamilam Posts: 9Questions: 3Answers: 0
edited September 2014 in Free community support

Hi,

I try to use Multi_Filter_Select with Row_Details (ajax).
We can see the select box but there are no data. It's not possible to use live.datatables.net with ajax data.

So i use private server to test: http://ilam.fr/help/T/examples/api/row_details.html.

I have problem with this part of code to get data with the file objects.txt:

"table.column( i ).data().unique().sort().each( function ( d, j ) { //To full the select input. THE PROBLEME: i=column, j=line, d=data
//console.log("i: "+i+" and j: "+j);
select.append( '<option value="'+d+'">'+d+'</option>' )
} );"

Somebody can help me?

Thx,

Answers

  • daniel_rdaniel_r Posts: 460Questions: 4Answers: 67

    I guess you have to populate your select inputs after ajax load event... or you can use my yadcf plugin for that and get all this and more out of the box http://yadcf-showcase.appspot.com/DOM_Ajax_Multiple_1.10.html

  • ilamilam Posts: 9Questions: 3Answers: 0

    Thx for your answer Daniel.

    I use finaly PHP to full select but now, i have problem with the serch.
    var select = $('<?php echo $sel;?>')
    .appendTo( $(this).empty() )
    .on( 'change', function () {
    var val = $(this).val();
    table.column( i )
    .search( val ? '^'+$(this).val()+'$' : val, true, false )
    .draw();
    } );
    } );

    Can you help me?
    Tkx,

  • daniel_rdaniel_r Posts: 460Questions: 4Answers: 67

    not a php user... sorry...

  • ilamilam Posts: 9Questions: 3Answers: 0

    Ok, but your plugin is really interesting. I will use it in my projet.
    Thx,

  • ilamilam Posts: 9Questions: 3Answers: 0
    edited September 2014

    Hi,
    The answer is to use initComplete.

     initComplete: function () {
            var api = this.api();
            api.columns().indexes().flatten().each( function ( i ) {
            if(i!=0){
                var column = api.column( i );
                // console.log( i );
                var select = $('<select><option value=""></option></select>')
                .appendTo( $(column.footer()).empty() )
                .on( 'change', function () {
                    var val = $(this).val();
                    column
                        .search( val ? '^'+$(this).val()+'$' : val, true, false )
                        .draw();
                } );
                column.data().unique().sort().each( function ( d, j ) {
                    select.append( '<option value="'+d+'">'+d+'</option>' )
                } );
            }
            } );
            
        }
    

    Thx to Allan,

This discussion has been closed.