URL Parameters and Dropdown Select
URL Parameters and Dropdown Select

Hello,
I used two examples together. The first was creating URL Parameters which I passed through:
function getPillar(){
var pillarName = window.location.search.substring(1).replace('pillar=', '').replace('%20', ' ')
return pillarName;
}
This is just a snippet:
$('#lesson-table').DataTable( {
'data': """ + str(self.get_lessons()) + """,
'paging': false,
'order': [[ 8, 'asc' ], [ 3, 'desc' ], [ 1, 'desc' ]],
initComplete: function () {
this.api().columns([3]).search(getPillar()).draw();
The second thing I did was create a dropdown using this (in the same initComplete as above):
*** Used this Instructions ***
this.api().columns([0,4,5,6,7,8]).every( function () {
var column = this;
var select = $('<select><option value=""></option></select>')
.appendTo( $(column.header()) )
.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 ) {
var val = $('<div/>').html(d).text();
select.append( '<option value="' + val + '">' + val + '</option>' );
} );
} );
These things work, but I'd love the values in my dropdown to be filtered by the URL Parameter. What is the best way to do this?
Thanks.
This discussion has been closed.
Answers
I don't quite follow, sorry, but I would expect you would change line 17 above to behave like your
getPillar()
, i.e get those values from the URL parameters.Colin