Resize column select as column width
Resize column select as column width
saulosag
Posts: 1Questions: 1Answers: 0
I'm trying to implement a filter for specific columns. The every() of said columns is being delegated to the function below, but width is always turning out to be undefined. What am I doing wrong? Can somenone suggest another way to resize the select as the same width as the column?:
function filtroColuna () {
var column = this;
var width = column.width;
console.log(width);
var select = $('<select style="max-width:'+width+'px"><option value="">'+this.header().innerHTML+'</option></select>')
.appendTo( $(column.header()).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>')});
}
This discussion has been closed.