Multi-Column Filtering - Numbers not displaying correctly in dropdown options
Multi-Column Filtering - Numbers not displaying correctly in dropdown options
lc180
Posts: 7Questions: 3Answers: 0
I have just started using multi-column filtering and its really cool. Only problem I've found is that the sample provided works perfectly for my text based columns but when I have columns with numeric values its does not display correctly in the dropdown box.
Instead of a dropdown with options like 1234 & 5678, its has options 1234'">1234 & 5678'">5678
I'm guessing I need to tweak the sample code slight but I'm exactly sure how. Any suggestions?
table.column( i ).data().unique().sort().each( function ( d, j ) {
select.append( '<option value="'+d+'">'+d+'</option>');
} );
This discussion has been closed.
Answers
I'm not sure you can use jQuery string concatenation like that in your example. Try either spacing out the operators, e.g.
'<option value="' + d + '">' + d + '</option>')
or look at using toString() on your numbers. I'm no expert though.
I've done some more debugging and I think I've found the cause.
The fact that its a numeric value is not the problem, I am formatting the value to be a hyperlink before it reaches the filter code so instead of selecting 1234 from the column it is selecting code below as well.
'<a href="example.com/itemId='+1234+'" target="_blank">'+ 1234 + '</a>'