Filter Datatable from Dashboard

Filter Datatable from Dashboard

ctechukctechuk Posts: 12Questions: 5Answers: 0

Evening all,

I am trying to build some stats on my dashboard and would like to be able to add links that will take me to specific data results.

For example, showing how many products are showing active. Clicking that link will take me to the products page already loaded with data filtered by all those products active.

What would be the best practice to achieve this? Any examples would be greatly appreciated.

Many thanks in advance for any help.

Ctech UK

Answers

  • kthorngrenkthorngren Posts: 20,317Questions: 26Answers: 4,772

    Clicking that link will take me to the products page already loaded with data filtered by all those products active.

    Here are a couple options I can think of:

    1.You could use the ajax.data option to pass the filter to the server script and let it use the filter for the DB query.
    2. If the Datatable is already laded with all the data then use search() to filter the Datatables display.

    Kevin

  • ctechukctechuk Posts: 12Questions: 5Answers: 0

    Kevin,

    thanks for your advice. I resolved it by adding a simple piece of logic in my js

    if(divRequest == 'all')  {
            console.log(divRequest);
            var myurl = "php_action/fetchProduct.php";
            console.log(myurl);
        } else if (divRequest == 'sold') {
            console.log(divRequest);
            var myurl = "php_action/fetchSoldProduct.php";
            console.log(myurl);
        } else if (divRequest == 'reserved') {
            console.log(divRequest);
            var myurl = "php_action/fetchReservedProduct.php";
        }
    

    It is not elegant, however is solves my issue for now unless i need to change anything in the associated fetch files which will need to be changed in triplicate.

    I will look for a more elegant solution when I have time.

    Thanks again.

    Ctech.

This discussion has been closed.