Floating and dynamically resizing input fields above their respective columns
Floating and dynamically resizing input fields above their respective columns
mrashkovsky
Posts: 9Questions: 0Answers: 0
Is there a recommended solution for having input fields on a per-column basis, and having those filter fields stay above each column and resize dynamically with the columns? I've implemented something using jqueryui's position functionality ( http://jqueryui.com/position/ ) but just wondering if there are any other good solutions for this problem.
The test case would be when resizing the window, or paging through data that changes the widths of the columns, that the filter fields should resize their widths automatically. Also that when the page loads the filter fields position themselves right above each column.
The test case would be when resizing the window, or paging through data that changes the widths of the columns, that the filter fields should resize their widths automatically. Also that when the page loads the filter fields position themselves right above each column.
This discussion has been closed.
Replies
Allan
Allan
$( window ).on( 'resize', function(){
// Position the input elements using jqueryui's position functionality
// Use jquery to match the size of the columns
});
It just seemed a little janky to do this so just wanted to check if there was something in the datatables API that I might have missed. Thanks a bunch for confirming for me, and thanks again for datatables which is a pleasure to use.
Allan
[code]
positionFilters: function(){
var filter_to_column_header_mappings = [
{
filter : 'input#birth_date',
header : 'th#birth_date'
},
{
filter : 'input#person_initials',
header : 'th#person-initials-head'
},
{
filter : 'input#fuser_id',
header : 'th#userid-head'
},
];
_.each( filter_to_column_header_mappings, function( mapping ){
$( mapping.filter ).css({
'width' : $( mapping.header ).outerWidth() - 20,
'margin' : '0'
});
$( mapping.filter ).position({
my: 'center bottom-6',
at: 'center top',
of: mapping.header,
collision: 'none'
});
});
}
[/code]