最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

javascript - How to Change position length menu of Datatable? - Stack Overflow

matteradmin8PV0评论

Can I move length menu to beside search part label ?

Can I move the length with CSS only ? Or we need dom basic as like this discussion I was try it but I don't know how to move with specify position

here is my following code to init datatable:

  table = $('#sparepart_id').DataTable({
        "paging": true,
        "stateSave": true,
        "pagingType": "full_numbers",
        "lengthChange": true,
        "searching": false,
        "ordering": true,
        "info": false,
        "autoWidth": false,
        "pageLength": 25,
        scrollX: true,
       stateLoadCallback: function (settings) {
         var o;
         $.ajax( {
            url     : BASE_URL+"spareparts/load_layout",
            type    : "POST",
            data    : { module_table : "sparepart-list"},
            async   : false,
            dataType: 'json',
             success: function (json) {
                 o = JSON.parse(json.json);
             },
             error:function(data){
                console.log(data);
             }
         } );
         return o;
     }

Can I move length menu to beside search part label ?

Can I move the length with CSS only ? Or we need dom basic as like this discussion I was try it but I don't know how to move with specify position

here is my following code to init datatable:

  table = $('#sparepart_id').DataTable({
        "paging": true,
        "stateSave": true,
        "pagingType": "full_numbers",
        "lengthChange": true,
        "searching": false,
        "ordering": true,
        "info": false,
        "autoWidth": false,
        "pageLength": 25,
        scrollX: true,
       stateLoadCallback: function (settings) {
         var o;
         $.ajax( {
            url     : BASE_URL+"spareparts/load_layout",
            type    : "POST",
            data    : { module_table : "sparepart-list"},
            async   : false,
            dataType: 'json',
             success: function (json) {
                 o = JSON.parse(json.json);
             },
             error:function(data){
                console.log(data);
             }
         } );
         return o;
     }
Share Improve this question edited Oct 12, 2018 at 14:09 babar junaid 991 silver badge12 bronze badges asked Oct 12, 2018 at 8:06 Not a PwntesterNot a Pwntester 251 gold badge1 silver badge6 bronze badges 2
  • [SOLVED] thank you – Not a Pwntester Commented Oct 12, 2018 at 8:32
  • You can post your solution (i.e answer your own question) and mark it as accepted answer. Perhaps it can help other people in the future. – davidkonrad Commented Oct 12, 2018 at 8:34
Add a ment  | 

3 Answers 3

Reset to default 1
$(document).ready(function() {
$('#example').DataTable( {
    "dom": '<"top"i>rt<"bottom"flp><"clear">'
} );

} );

For More Information : https://datatables/release-datatables/examples/basic_init/dom.html

My Solution :

i just inspect element and looking what class in length menu datatable then put css code in my view

      .dataTables_length{
        margin-top : -57px;
        margin-left: 20px;
       }

move with specifying position should use dom property. There is an example may be helpful.

$('#example').DataTable( {
     "dom": '<"toolbox"l>rtip',
     //... your another config,
     "initComplete":function(){
          //build your search layout here
         $(".toolbox").append("<label>search part</label><input>");         
     }
} );

l means Length changing feature, <"toolbox"l> will bees

<div class="toolbox">
    {Length changing}
    <label>search part</label><input>
</div>"

{Length changing} build by DataTables, you don't need care about it.

For More Information : https://datatables/release-datatables/examples/basic_init/dom.html

Post a comment

comment list (0)

  1. No comments so far