How can i change the search bar side? from the right to the left?

How can i change the search bar side? from the right to the left?

PsyBootPsyBoot Posts: 6Questions: 1Answers: 0

How can i change the search bar side? from the right to th
e left?

Answers

  • MSLtdMSLtd Posts: 56Questions: 5Answers: 4


    Hello @PsyBoot - If you see in the image above, the float style assigned to dataTables_Filter is float:right;. Can you try adding this in your HTML head:

    <style>
        #dataTables_Filter{
            float: left;
        }
    </style>
    

    If it doesn't work how you'd like paste the result here and we'll go from there.

  • PsyBootPsyBoot Posts: 6Questions: 1Answers: 0
    edited July 2018

    Hi, @MSLtd Thx for the reply.

    Dint work... my table dont have that "dataTables_filter" its like that:
    https://prnt.sc/k8g41f

    if i change the order from the DIV draw the search one first then the other one will work...
    like this (i use the chrome tool to edit the html)
    http://prntscr.com/k8g5v9

    Edit: BTW im using Bootstrap4 dont know if changes any thing

  • MSLtdMSLtd Posts: 56Questions: 5Answers: 4

    @PsyBoot - My apologies, there was a small typo in my code sample, it's #dataTables_filter rather than #dataTables_Filter.

    Whilst in the elements inspector, can you right click on <html>, select 'edit as HTML', then key Ctrl+A then Ctrl+C, and then paste it in a comment here in this format:

    ```html
    //your html here
    ```

    I'll have a look at it for you :)

  • PsyBootPsyBoot Posts: 6Questions: 1Answers: 0
    edited July 2018

    @MSLtd Thx again...
    Well no change on dataTables_filter here is the html

    I think the change should be on the JS from the datatables where is the draw order for the things but here the code
    Cant post the compleat code its too long

    this is the code that need to change

    <div id="exames_wrapper" class="dataTables_wrapper dt-bootstrap4 no-footer">
     <div class="row">
       <div class="col-sm-12 col-md-6">
            <div class="dataTables_length" id="exames_length">
             <label><select name="exames_length" aria-controls="exames" class="custom-select custom-select-sm form-control form-control-sm"><option value="10">10</option><option value="25">25</option><option value="50">50</option><option value="100">100</option>
    </select> resultados por página</label>
                </div>
           </div>
        <div class="col-sm-12 col-md-6">
      <div id="exames_filter" class="dataTables_filter">
    <label>Pesquisar<input type="search" class="form-control form-control-sm" placeholder="" aria-controls="exames"></label>
     </div>
    </div>
    </div>
    <div class="row">
    <div class="col-sm-12">
    <table id="exames" class="table table-striped table-bordered bg-white fix-phone dataTable no-footer" style="width:100%" role="grid" aria-describedby="exames_info">
    
    
    <div class="content">
                  <div class="results">
                    <div class="col-md-12">
                      <div id="exames_wrapper" class="dataTables_wrapper dt-bootstrap4 no-footer"><div class="row"><div class="col-sm-12 col-md-6"><div class="dataTables_length" id="exames_length"><label><select name="exames_length" aria-controls="exames" class="custom-select custom-select-sm form-control form-control-sm"><option value="10">10</option><option value="25">25</option><option value="50">50</option><option value="100">100</option></select> resultados por página</label></div></div><div class="col-sm-12 col-md-6"><div id="exames_filter" class="dataTables_filter"><label>Pesquisar<input type="search" class="form-control form-control-sm" placeholder="" aria-controls="exames"></label></div></div></div><div class="row"><div class="col-sm-12"><table id="exames" class="table table-striped table-bordered bg-white fix-phone dataTable no-footer" style="width:100%" role="grid" aria-describedby="exames_info">
                        <thead>
                            <tr role="row"><th class="sorting_asc" tabindex="0" aria-controls="exames" rowspan="1" colspan="1" aria-sort="ascending" aria-label="Data: Ordenar colunas de forma descendente" style="width: 195px;">Data</th><th class="sorting" tabindex="0" aria-controls="exames" rowspan="1" colspan="1" aria-label="Solicitante: Ordenar colunas de forma ascendente" style="width: 357px;">Solicitante</th><th class="sorting" tabindex="0" aria-controls="exames" rowspan="1" colspan="1" aria-label="Categoria: Ordenar colunas de forma ascendente" style="width: 226px;">Categoria</th><th class="sorting" tabindex="0" aria-controls="exames" rowspan="1" colspan="1" aria-label="Exame: Ordenar colunas de forma ascendente" style="width: 206px;">Exame</th><th class="sorting" tabindex="0" aria-controls="exames" rowspan="1" colspan="1" aria-label="Opções: Ordenar colunas de forma ascendente" style="width: 561px;">Opções</th></tr>
                        </thead>
                        <tbody>
                            
                            
                        <tr role="row" class="odd">
                                <td class="sorting_1">07/06/1990</td>
                                <td>Dr. Medico Solicitante</td>
                                <td>Raio X</td>
                                <td>Rx - Quadril</td>
                                <td>
                                    <button type="button" class="btn-icons btn-primary mb-2 " data-toggle="modal" data-target=".bd-example-modal-lg" title="Visualizar"><i class="fa fa-eye"></i></button>
                                    <button type="button" class="btn-icons btn-primary mb-2" title="Download"><i class="fa fa-download"></i></button>
                                    <button type="button" class="img-icons mb-2" title="Download"> <img class="img-icon" src="./res/vendor/img/pdf-icon.png"> </button>
                                    <button type="button" class="img-icons mb-2" title="Download"> <img class="img-icon" src="./res/vendor/img/osirix-icon.png"> </button>
                                </td>
                            </tr><tr role="row" class="even">
                                <td class="sorting_1">15/06/1998</td>
                                <td>Dr. Medico Solicitante</td>
                                <td>Raio X</td>
                                <td>Rx - Torax</td>
                                <td>
                                    <button type="button" class="btn-icons btn-primary mb-2 " data-toggle="modal" data-target=".bd-example-modal-lg" title="Visualizar"><i class="fa fa-eye"></i></button>
                                    <button type="button" class="btn-icons btn-primary mb-2" title="Download"><i class="fa fa-download"></i></button>
                                    <button type="button" class="img-icons mb-2" title="Download"> <img class="img-icon" src="./res/vendor/img/pdf-icon.png"> </button>
                                    <button type="button" class="img-icons mb-2" title="Download"> <img class="img-icon" src="./res/vendor/img/osirix-icon.png"> </button>
                                </td>
                            </tr></tbody>
                       
                    </table></div></div><div class="row"><div class="col-sm-12 col-md-5"><div class="dataTables_info" id="exames_info" role="status" aria-live="polite">Mostrando de 1 até 2 de 2 registros</div></div><div class="col-sm-12 col-md-7"><div class="dataTables_paginate paging_simple_numbers" id="exames_paginate"><ul class="pagination"><li class="paginate_button page-item previous disabled" id="exames_previous"><a href="#" aria-controls="exames" data-dt-idx="0" tabindex="0" class="page-link">Anterior</a></li><li class="paginate_button page-item active"><a href="#" aria-controls="exames" data-dt-idx="1" tabindex="0" class="page-link">1</a></li><li class="paginate_button page-item next disabled" id="exames_next"><a href="#" aria-controls="exames" data-dt-idx="2" tabindex="0" class="page-link">Próximo</a></li></ul></div></div></div></div>
                      <div class="modal bd-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
                        <div class="modal-dialog">
                          <div class="modal-content">
                            <div class="modal-header">
                              <h5 class="modal-title">Nome do exame</h5>
                              <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                <span aria-hidden="true">×</span>
                              </button>
                            </div>
                            <div class="wrapper">
                              <div class="modal-body">
                                <div class="embed-responsive  embed-responsive-16by9 iframe ">
                                  <iframe class="embed-responsive-item iframe" src="http://www.pdf995.com/samples/pdf.pdf"></iframe>
                                </div>
                              </div>
                            </div>
                          </div>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
    
  • MSLtdMSLtd Posts: 56Questions: 5Answers: 4
    edited July 2018

    Ahhh @PsyBoot - I've been a total doofus!! I often mix-up classes and identities in CSS... I've been asking you to set the style for an id whilst the dataTables_filter is a class! :astonished:

    try this style instead:

    <style>
        .dataTables_Filter{
            float: left;
        }
    </style>
    

    What I'm changing is the: '#' (id identifier) to: '.' (class identifier) - This should make the styling work :)

    -EDIT: I've tested it, and it's still causing some issues. Give me a moment and I'll get back to you :)

  • MSLtdMSLtd Posts: 56Questions: 5Answers: 4
    edited July 2018


    This here is the solution! you need to pop this in between your <head> </head> tags - shouldn't matter where.

    <style>
        .dataTables_filter{
            float: left !important;
        }
    </style>
    
  • PsyBootPsyBoot Posts: 6Questions: 1Answers: 0

    Hey dint work... i post a example online so u can see it

    http://mect.com.br/pmedicoonline/index.html

    Thx again! u rock!

  • PsyBootPsyBoot Posts: 6Questions: 1Answers: 0

    hm cant find a way to make it work '-'

    @MSLtd what u think about it?

  • bindridbindrid Posts: 730Questions: 0Answers: 119

    You are missing the style for the length box

      .dataTables_wrapper   .dataTables_filter{
            float: left 
        }
    
     .dataTables_wrapper  .dataTables_length{
            float: right 
        }
    

    http://live.datatables.net/vahicoyu/1/edit

  • MSLtdMSLtd Posts: 56Questions: 5Answers: 4

    Ah, that's a problem... your search bar and length selector are in separate Divs with Bootstrap styles making them take up half the page each. How much control do you have over the bootstrap classes assigned in the HTML @PsyBoot

  • MSLtdMSLtd Posts: 56Questions: 5Answers: 4

    @PsyBoot

    You need to remove these classes if you can, because at the moment on a medium screen+ they span 50% of the page, and on a small screen each one will span the whole screen.
    The result should look like this:

    I've added a temporary embedded CSS class to replace the styling lost by omitting the Bootstrap styles:

    <style>.class{margin-left:15px;}</style>

  • PsyBootPsyBoot Posts: 6Questions: 1Answers: 0

    Ah, that's a problem... your search bar and length selector are in separate Divs with Bootstrap styles making them take up half the page each. How much control do you have over the bootstrap classes assigned in the HTML @PsyBoot

    @MSLtd I cant remove, the datatables add`s them automatic, i dont have any control... they draw the divs by the datatables js

    ther is any js code that get`s the parent of a element ?

  • MSLtdMSLtd Posts: 56Questions: 5Answers: 4

    @PsyBoot , You're in luck!

    There just so happens to be this:
    $('#exames_filter').parent(); <- this will return the element that is the parent of the div.
    .attr( "col-sm-12 col-md-6", "class" ) <- you can then use this to remove the bootstrap class, and replace it with your own.

  • MSLtdMSLtd Posts: 56Questions: 5Answers: 4

    @PsyBoot , after that, you'd need to assign an id to the length search.
    I'd recommend looking into: jquery .closest();.

This discussion has been closed.