Add additional filter drop-down to same line as dataTable search

Add additional filter drop-down to same line as dataTable search

AmenRaAmenRa Posts: 7Questions: 1Answers: 0
edited September 2015 in Free community support

I have a dataTable (v 1.9) in where I have an additional 'filter' using a drop-down. However, the additional filter appears on a line above the dataTables 'Search' option. I would like the two to be on the same 'line'. I can't seem to figure out how to accomplish this. Anyone have a solution?

Answers

  • ThomDThomD Posts: 334Questions: 11Answers: 43

    I think I know what you mean, but please post your sample code.

  • AmenRaAmenRa Posts: 7Questions: 1Answers: 0

    The application is using bootstrap 2.3.2.

    So, the result looks like this (crude layout)

    Region: [Drop-down listbox]
    (blank line)
    Search: [Datatables Text Box]
    

    but I want the layout to look like this (same line):

    Region: [Drop-down listbox]     Search: [Datatables Text Box]
    

    And the code...

    <div class="span8">
        <legend>
            <center>
                {{  Lang::get( 'lwfcltt.matrix.field.origin_id.label' ) }}
                <a href="{{ action( 'LWFCLTTController@addUsing', array( 'source' => 'O', 'id' => $UN_LOCATION -> id ) ) }}" title="{{ Lang::get( 'lwfcltt.button.addOrigin.tooltip' ) }}">
                    {{ HTML::image( Config::get( 'theme.icon.add' ), Lang::get( 'lwfcltt.button.add.label' ) ) }}
                </a>
            </center>
        </legend>
    
        {{ Form::open( array( 'class' => 'form-inline', 'id' => 'formOriginRegion', 'name' => 'formOriginRegion' , 'url' => '/lw/fcl/tt/matrix', 'files' => false ) ) }}
        {{ Form::hidden( 'un_location_id', $UN_LOCATION -> id ) }}
        {{ Form::label( 'origin_descod', Lang::get( 'lwfcltt.matrix.filter.descod.label' ), array( 'class' => 'control-label' ) ) }}
        {{ Form::select( 'origin_descod', $Regions, $OriginDesCod, array( 'class' => '', 'data-content' => Lang::get( 'lwfcltt.matrix.filter.descod.help' ), 'id' => 'selectOriginRegion', 'rel' => 'popover', 'required' => 'required' ) ) }}
        {{ Form::hidden( 'destin_descod', $DestinDesCod) }}
        {{ Form::close() }}
    
        <table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered" id="tableOrigins" >
    
            <thead>
                <tr>
                    <th class="justifyLeft">{{ Lang::get( 'lwfcltt.fcl_tt.field.origin_id.label' ) }}</th>
                    <th class="justifyLeft">{{ Lang::get( 'lwfcltt.fcl_tt.field.sp_acct_no.label' ) }}</th>
                    <th class="justifyCenter">{{ Lang::get( 'lwfcltt.fcl_tt.field.hazmat_permitted.label' ) }}</th>
                    <th class="justifyCenter">{{ Lang::get( 'lwfcltt.fcl_tt.field.tt.label' ) }}</th>
                    <th class="justifyCenter"></th>
                </tr>
            </thead>
    
            <tbody>
    </table>
    
    ...
    
                /* Init Origins dataTable */
                var oOriginsTable = $( '#tableOrigins' ).dataTable(
            {
            "sDom": "f<'row'<'span6'l>r>t<'row'<'span6'i><'span6'p>>",
                "bPaginate": false,
                "aoColumnDefs":
                [
                { bSortable: true, aTargets: [ 0, 1 ] },
                { bSortable: false, aTargets: [ '_all' ] },
                {
                "fnCreatedCell": function ( nTd, sData, oData, iRow, iCol )
                {
                if ( typeof ( nTd.attributes[ "data-changed" ] ) != "undefined" && nTd.attributes[ "data-changed" ].value === "true" )
                {
                $( nTd ).css( 'color', 'blue' );
                }
                },
                    "aTargets": [ '_all' ]
                }
                ]
            } );
    ....
    
  • ThomDThomD Posts: 334Questions: 11Answers: 43

    I don't know anything about bootstrap, but if it is a simple question of formatting the HTML in the cell, I'd use jQuery to move the DOM elements around. Can you post a couple of samples of the HTML for some cells?

This discussion has been closed.