How to filterout the non related

How to filterout the non related

troshantroshan Posts: 2Questions: 1Answers: 0

I have a table which has columns 'client Name' and 'project name'. If I filter first column(client Name) by client name the second column(project name) filter need to be show only projects which related to the client which I selected. Right now it shows all the projects.

Here is my code. How can tweak this to meet my requirement?

$(document).ready(function() {
$('#tblclient').DataTable( {
    initComplete: function () {
        this.api().columns('.filter').every( function () {
            var column = this;
               var select = $('<select><option value="">--All--</option></select>')
                .appendTo( $(column.footer()).empty() )
                .on( 'change', function () {
                    var val = $.fn.dataTable.util.escapeRegex(
                        $(this).val()
                    );

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

            column.data().unique().sort().each( function ( d, j ) {
                select.append( '<option value="'+d+'">'+d+'</option>' )
            } );
        } );
    }
   } );
   } );

Answers

This discussion has been closed.