Searchable not working

Searchable not working

NymesiaNymesia Posts: 4Questions: 1Answers: 0

Hi everyone,

I need some help, about my Datatable.
I use Datatable in lot of page with the same base et the same version.
But actually I have a problem : the functionality "searchable" don't working, whereas my others pages with Datatable and the functionality "searchable" works correctly.

<cfoutput>
    <table class="normal" width="100%" border="0" cellspacing="1" cellpadding="2" id="listeReferencement">
        <thead>
            <tr>
                <th>Agence</th>
                <th>ETT</th>
                <th>Référencer / Déréférencer</th>
                <th>Origine : BAPS-ETT</th>
            </tr>
        </thead>
        <tbody>
        </tbody>
    </table>
</cfoutput>

<script type="text/javascript">
    $(document).ready(function(){
        var oTable = $('#listeReferencement').dataTable(
        {
             "bProcessing": true
            ,"bServerSide": true
            ,"sAjaxSource": "./paging/processPaging.cfm?type=referencerAgences"
            ,"aoColumns":
            [
                {"sWidth": "15%"},
                {"sWidth": "10%"},
                {"sWidth": "1%"},
                {"sWidth": "1%"}
            ]
            ,"aoColumnDefs": [
                { "bSearchable": false, "aTargets": [2,3] },
                { "sClass": "center", "aTargets": [2,3] }
            ]
            ,"fnInitComplete": function(oSettings, json) {
                    new FixedHeader( oTable, {"offsetTop": offtop});
            }
        });
    });
</script>

I can't post a screenshot, but I have 4 columns, and the two last are with the html code : "<img src='image.png'>"
So, I preclude this two columns, because I thinking it's the problem but... No.

I have in Firebug : "TypeError: json is null"
I can try to search with a "a" but with an other character not working, like "b" or anything...
I try to debug since 2 days I become crazy... If you have any idea, I take her

Thank you in advance and good evening,

Nymesia

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,760Questions: 1Answers: 10,510 Site admin

    "bServerSide": true

    Sounds like the server-side script you are using isn't correctly implement the client / server-side protocol that DataTables uses. See the legacy manual since you appear to be using the legacy options.

    Allan

  • NymesiaNymesia Posts: 4Questions: 1Answers: 0
    edited November 2015

    Hi,

    Thanks for your response, I had tried to use this manual before to come and ask my question. I will try to do more precise because I haven't my solution.

    I don't find my error....

    I send :

    (without search and that works)

    processPaging.cfm?
    type=referencerAgences
    &sEcho=6
    &iColumns=4
    &sColumns=
    &iDisplayStart=0
    &iDisplayLength=10
    &mDataProp_0=0
    &mDataProp_1=1
    &mDataProp_2=2
    &mDataProp_3=3
    &sSearch=
    &bRegex=false
    &sSearch_0=
    &bRegex_0=false
    &bSearchable_0=true
    &sSearch_1=
    &bRegex_1=false
    &bSearchable_1=true
    &sSearch_2=
    &bRegex_2=false
    &bSearchable_2=false
    &sSearch_3=
    &bRegex_3=false
    &bSearchable_3=false
    &iSortCol_0=0
    &sSortDir_0=asc
    &iSortingCols=1
    &bSortable_0=true
    &bSortable_1=true
    &bSortable_2=true
    &bSortable_3=true
    &_=1447061355027
    
    /// with the response :
    
    {
        "sEcho": 14,
        "iTotalRecords": 216,
        "iTotalDisplayRecords": 216,
        "aaData": [
                    ["11281_CENTREGESTION",
                     "158_ETT",
                     "<a href='referencerfournisseurs_traitement.cfm?id_referencer_client
    =11281' title='Référencer cette agence'><img style='width:20px;' alt='Référencer' src='images_fr/ico_Referencer
    .png'></a>",
                     "&nbsp;"
                    ],
                    ["11282_CENTREGESTION",
                     "158_ETT",
                     "<a href='referencerfournisseurs_traitement.cfm
    
    <?php
    id_referencer_client=11282' title='Référencer cette agence'>
    Référencer", " " ] ] } ?>

    with search and the response that is "Json is null" :

    ProcessPaging.cfm?
    type=referencerAgences
    &sEcho=5
    &iColumns=4
    &sColumns=
    &iDisplayStart=0
    &iDisplayLength=10
    &mDataProp_0=0
    &mDataProp_1=1
    &mDataProp_2=2
    &mDataProp_3=3
    &sSearch=ett
    &bRegex=false
    &sSearch_0=
    &bRegex_0=false
    &bSearchable_0=true
    &sSearch_1=
    &bRegex_1=false
    &bSearchable_1=true
    &sSearch_2=
    &bRegex_2=false
    &bSearchable_2=false
    &sSearch_3=
    &bRegex_3=false
    &bSearchable_3=false
    &iSortCol_0=0
    &sSortDir_0=asc
    &iSortingCols=1
    &bSortable_0=true
    &bSortable_1=true
    &bSortable_2=true
    &bSortable_3=true
    &_=1447061214388
    
    /// with the response :
    
    Json is null
    

    Just sEcho is different, is it important ??
    I try to understand but I don't know where is the bug !

    Nymesia

  • allanallan Posts: 63,760Questions: 1Answers: 10,510 Site admin
    Answer ✓

    sEcho is important if you are using the legacy server-side protocol - from the documentation:

    An unaltered copy of sEcho sent from the client side. This parameter will change with each draw (it is basically a draw count) - so it is important that this is implemented. Note that it strongly recommended for security reasons that you 'cast' this parameter to an integer in order to prevent Cross Site Scripting (XSS) attacks.

    However, I would be truly amazed if a different sEcho is causing the JSON data to return a null value.

    The null suggests to me that the server-side script is not coping with the data in the database. Have you checked your server's errors logs for any debug information.

    Allan

  • NymesiaNymesia Posts: 4Questions: 1Answers: 0

    And with an other Datatable of my application who working correctly I have :

    processPaging.cfm?
    type=bordereaux
    &columns_tri=multi,'',matricule,interimaire,sinitcontrat,libelCC1,libelCC2,libelCC15
    &columns_filter=interimaire,snomett,snomagence,periode_filter
    &columns_cc=libelCC1,libelCC2,libelCC15
    &type_liste=0
    &retour=bordereau_liste.cfm?type%3D0&VEM=0&dv=1&ds=1
    &sEcho=3
    &iColumns=8
    &sColumns=
    &iDisplayStart=0
    &iDisplayLength=10
    &mDataProp_0=0
    &mDataProp_1=1
    &mDataProp_2=2
    &mDataProp_3=3
    &sSearch=131
    &bRegex=false
    &sSearch_0=
    &bRegex_0=false
    &bSearchable_0=true
    &sSearch_1=
    &bRegex_1=false
    &bSearchable_1=true
    &sSearch_2=
    &bRegex_2=false
    &bSearchable_2=true
    &sSearch_3=
    &bRegex_3=false
    &bSearchable_3=true
    &iSortCol_0=0
    &sSortDir_0=asc
    &iSortingCols=1
    &bSortable_0=false
    &bSortable_1=false
    &bSortable_2=true
    &bSortable_3=true
    &_=1447063595036
    
    /// with the response correct
    
    {
        "sEcho": 3,
        "iTotalRecords": 2685,
        "iTotalDisplayRecords": 32,
        "aaData":
                [
                    ["<img src='/ABA/DEVELOPPEMENT/client/REFERENCE/dyn/priv/images/bordereau_liste/multi.png' title='Multi : 1' />",
                     "<input type=\"checkbox\" id=\"chkb326421\" name=\"GenerAuto\">",
                     39503,
                     "<a class
    =\"normal\" href=\"../bordereaux/bordereau_load.cfm?type_liste=0&idbordereau=326421&retour=bordereau_liste
    .cfm?type=0\">39503_NOM 39503_PRENOM</a>",
                     "11643083_PRENOM 11643083_NOM",
                     "BNPP",
                     13100000,
                     "000000088042"
                    ],
                    ...
                ]
    }
    

    I had deleted the columns 4 to 7 but it's the same model =/
    It's with a lot of type of html etc... I'm really lost with this problem.

    Nymesia

  • NymesiaNymesia Posts: 4Questions: 1Answers: 0

    Oh my god it's working !

    Thanks you so much !

    I had deleted of my where clause, the columns with "img" because I send a "column_filter" in my where clause of my query... So it is impossible to have an image in my query return...

    It's working perfectly !

    Thanks again !

    Good evening to you,

    Nymesia

This discussion has been closed.