This topic contains 6 replies, has 2 voices, and was last updated by Jai Jai 7 months, 3 weeks ago.

DTATATABLE SOURCES


  • valeriometronic
    Participant

    Posts: 3
    Member Reply #15470

    How  can  find  the ajax (server side)  php script, to use in datatable component,  for read data from mysql database?

    Valerio

     

     

    Jai
    Jai
    Keymaster

    Posts: 2700
    Support Staff Reply #15500

    Hi 🙂

    You can check the sample demo init from this js file.

    /src/js/demo/default/custom/components/datatables/base/data-ajax.js

    Please note, after modification of any js files, you need to recompile the assets using gulp.

    Please check our documentation on how to compile.

    Backend demo script; /docs/api_reference/datatables/demos/default.php

    Thanks


    valeriometronic
    Participant

    Posts: 3
    Member Reply #15650

    Thanks SUPPORT STAFF,

    You does indicate me how find the  ajax server side script, i used it, but the  “usort” functionality doesn’t work properly.

    Maybe there is some mistake into the code inside the following scirpt:

    usort($data, function ($a, $b) use ($sort, $field) {

    if ( ! isset($a->$field) || ! isset($b->$field)) {

    return false;

    }

    if ($sort === ‘asc’) {

    return $a->$field > $b->$field ? true : false;

    }

    return $a->$field < $b->$field ? true : false;

    });

     

    Can you check please?

    Thanks

    Valerio Leonardis


    valeriometronic
    Participant

    Posts: 3
    Member Reply #15659

    Hi Support Staff,

    i solved (temporary) the previous issue with a simple operation:

    instead of “$a->$field”  i write $a[$field] and it works perfectly.

    I hope is correct or … any   idea?

    Thanks

     

    Valerio Leonardis

    Jai
    Jai
    Keymaster

    Posts: 2700
    Support Staff Reply #15692

    Hi Valerio Leonardis 🙂

    It depends on your own data variable from the database. You can var_dump() the whole data variable. You can see if it is an array or object.

    Our sample data is in stdObject, so you need “$a->$field” to access the object property. But need to use $a[$field] for array.

    You can read more about object and array here; https://stackoverflow.com/questions/931407/what-is-stdclass-in-php

    Thanks


    valeriometronic
    Participant

    Posts: 3
    Member Reply #16944
    This reply has been marked as private.
    Jai
    Jai
    Keymaster

    Posts: 2700
    Support Staff Reply #16986

    Hi 🙂

    Currently, our mDatatable does not support export data yet.

    We will improve our datatable for more features in the future updates.

    Thanks

You must be logged in to reply to this topic.