Search-Builder-Bug?

Search-Builder-Bug?

Alle_XAlle_X Posts: 7Questions: 1Answers: 0

Hello.

I use the Search-Builder and save the state to my Database (so the user can save different user-filters). After loading the state again, I always got the error

**DataTables warning: table id=tabelle - Unknown paging action: 0. For more information about this error, please see http://datatables.net/tn/5**

So I took a look in the saved datas and saw, that the last entry is always ...,"page":"0"}

As if the page should be a certain string ('first, 'last', ... or an integer, I changed the data to ...,"page":0} and it is working perfecly. But DataTables itself saves the state still with ...,"page":"0"}. I made a workaround by parsing "0" to 0, but it seems to be like a little bug in the SearchBuilder-StateSaver.

Greetings from Hannover

Replies

  • kthorngrenkthorngren Posts: 14,635Questions: 25Answers: 3,475

    I created a test case for you with SearchBuilder:
    http://live.datatables.net/qokonicu/1/edit

    After performing a search and reloading the page I see this output from the retrieved state data:

    {time: 1617223013925, start: 0, length: 2, order: Array(1), search: {…}, …}
    columns: (6) [{…}, {…}, {…}, {…}, {…}, {…}]
    length: 2
    order: [Array(2)]
    page: 0
    search: {search: "", smart: true, regex: false, caseInsensitive: true}
    searchBuilder: {criteria: Array(2), logic: "AND"}
    start: 0
    time: 1617223013925
    

    And using console.log(typeof data.page) the result is number.

    Are you storing the data somewhere using stateSaveCallback? If so maybe the the page value is being changed to a string in your storage location or when its retrieved. Can you post a link to your page or a test case showing the issue?
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

  • Alle_XAlle_X Posts: 7Questions: 1Answers: 0

    I create the Datatable with that code:

    $.fn.dataTable.moment( 'DD.MM.YYYY HH:mm' );
        table = $('#tabelle').DataTable({
            stateSave: true,
            stateSaveCallback: function (settings, data) {
                tabdata = data;
            },
            dom: 'Qlfrtip',
            "order": [[ 2, "asc" ]]
        });
    

    And onclick I save the tabdata to the database via

    tabdata['filtername'] = $('#tbNeuerFilter').val();
    tabdata['filterid'] = 0;
    (...)
    $.ajax( {
            url: "ajax_savestate.php",
            data: tabdata,
            dataType: "text",
            type: "POST",
            success: function () { 
                alert(ausgabe); 
                location.reload(); 
            }
    } );
    

    and

    $param = array();
    $param[] = $uid;
    $param[] = $filtername;
    $param[] = $filter_json;
    
    $db->query("REPLACE INTO filter values(NULL,?,?,?);",$param,false,false);
    
  • kthorngrenkthorngren Posts: 14,635Questions: 25Answers: 3,475

    Have you traced through all the statesave steps to see where the page property is a string ("0")?

    Maybe try the stateLoadParams and stateSaveParams events, like this:

    table = $('#tabelle')
      .on( 'stateSaveParams.dt', function (e, settings, data) {
            console.log('stateSaveParams event', data.page, typeof data.page);
        } )
        .on( 'stateLoadParams.dt', function (e, settings, data) {
            console.log('stateLoadParams event', data.page, typeof data.page);
        } )
        .DataTable({
            stateSave: true,
            stateSaveCallback: function (settings, data) {
                tabdata = data;
            },
            dom: 'Qlfrtip',
            "order": [[ 2, "asc" ]]
        });
    

    Kevin

  • Alle_XAlle_X Posts: 7Questions: 1Answers: 0

    You are right. I lose the int-type by postig the json as an array...

    Thank you for your help!

Sign In or Register to comment.