countries.php is missing from the download

countries.php is missing from the download

olivervogtolivervogt Posts: 6Questions: 2Answers: 0

Hi - I am trying out some functionality of the Editor - of particular interest is the example with cascading lists https://editor.datatables.net/examples/advanced/cascadingLists.html

It seems however there are (at least) two files missing from the downloads:
- cascadingLists.php (which can be copied from the example page)
- countries.php

This is the error from Chrome DevTools:
jquery-3.5.1.js:10099 POST http://192.168.100.188/EditorSamples/controllers/countries.php 404 (Not Found)

Where would I find the file?

Thanks.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Answer ✓

    Hi,

    Apologies for that - the cascadingLists example shouldn't actually be in the 2.0.5 release of Editor. The examples have got slightly out of sync with the demo packages there - it will be correct in 2.0.6!

    In the meantime, this is the countries.php file:

    <?php
    
    // DataTables PHP library
    include( "../lib/DataTables.php" );
    
    $values = $_REQUEST['values']['team.continent'];
    if (! $values) {
        echo json_encode( [] );
        return;
    }
    
    $countries = $db
        ->select( 'country', ['id as value', 'name as label'], ['continent' => $_REQUEST['values']['team.continent']] )
        ->fetchAll();
    
    echo json_encode( [
        'options' => [
            'team.country' => $countries
        ]
    ] );
    

    Allan

  • olivervogtolivervogt Posts: 6Questions: 2Answers: 0

    Thanks. This works well now.

Sign In or Register to comment.