Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery Datatable search box align left

I am using backbone and jQuery datatable. By default search box of datatable comes on right side - I want to align it to the left. Below is my code:

onDomRefresh: function(){
   $(this.el).find('table').dataTable({ "dom": '<"top"i>rt<"bottom"flp><"clear">',"bLengthChange": false });
}

enter image description here

But it's not working.

like image 616
user3106347 Avatar asked Nov 29 '14 19:11

user3106347


Video Answer


2 Answers

You can use something like

jQuery(document).ready(function($) {
    $(tableSelector).DataTable({
        "dom": '<"pull-left"f><"pull-right"l>tip'
    });
});

with

.pull-left{float:left!important;}
.pull-right{float:right!important;}

The result is this:

(Note that Twitter Bootsrap is used on the screenshot, for additional table styling)

More on DataTables DOM Manipulation can be found here.

like image 155
makrigia Avatar answered Oct 10 '22 02:10

makrigia


It looks like this is not possible with sDom manipulation but you can adjust css rule for .dataTables_filter in jquery.DataTables.css or preferably override this rule in a custom css file:

#table_div_id.dataTables_filter {
  float: right;
  text-align: right;
}

table_div_id is an id of container div used for initialization: $('#table_div_id').dataTable()

like image 39
Andrey Grachev Avatar answered Oct 10 '22 01:10

Andrey Grachev