Cascade Lists

Cascade Lists

cpshartcpshart Posts: 246Questions: 49Answers: 5

Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem:

Hi

I have setup cascade lists for industry, supersector, sector and subsector for a stock MySQL database table, which is working correctly when I select the industry, supersector etc. using datatables Editor.

When I edit the row, the dependent functions are automatically being invoked and the original selections are either being cleared or replaced by "default values ??"

Extract of Client File

                label: "industry_id:",
                name: "dm_stocks.industry_id",
                type: "select2",
                placeholder: "Select Industry",
                def: 999
           }, {
                label: "supersector_id:",
                name: "dm_stocks.supersector_id",
                type: "select2",
                placeholder: "Select Supersector",
                def: 999
           }, {
                label: "sector_id:",
                name: "dm_stocks.sector_id",
                type: "select2",
                placeholder: "Select Sector",
                def: 999
           }, {
                label: "subsector_id:",
                name: "dm_stocks.subsector_id",
                type: "select2",
                placeholder: "Select Subsector",
                def: 999
.... etc
 });
    
    /***********************************************************************
    * get supersector list dependent upon industry selection
    ************************************************************************/   
    editor.dependent( 'dm_stocks.industry_id', function ( val, data, callback ) {
    $.ajax( {
        url: "../../" + EDITOR_DIR + "/controllers/dview-get_supersector-1.00.php",
        // pass industry_id value to server php script
        data: { "industry_id": val },
        dataType: 'json',
        success     : function ( json ) {
                        callback( json );
                      }   
    });
    })  

    /***********************************************************************
    * get sectors list dependent upon supersector selection
    ************************************************************************/
    
    editor.dependent( 'dm_stocks.supersector_id', function ( val, data, callback ) {
    $.ajax( {
        url: "../../" + EDITOR_DIR + "/controllers/dview-get_sector![](https://datatables.net/forums/uploads/editor/tc/krxn0n7ixq4r.png "")
-1.00.php",
        // pass supersector_id value to server php script
        data: { "supersector_id": val },
        dataType: 'json',
        success     : function ( json ) {
                        callback( json );
                      }   
    });
    })
... etc

Extract of server file

        ,Field::inst( 'dm_stocks.industry_id' )
            ->searchPaneOptions(SearchPaneOptions::inst())
            ->options( Options::inst()
                ->table( 'dm_stocks_industry' )
                ->value( 'id' )
                ->label( 'code' )![](https://datatables.net/forums/uploads/editor/pa/m58s3dk1algn.png "")

                ->label( 'name' )
            )
            ->validator( Validate::notEmpty( ValidateOptions::inst()
                ->message( 'Please select industry ..' )
            ) )
        ,Field::inst( 'dm_stocks_industry.code' )
        ,Field::inst( 'dm_stocks_industry.name' )
        
        ,Field::inst( 'dm_stocks.supersector_id' )
            ->options( Options::inst()
                ->table( 'dm_stocks_supersectors' )
                ->value( 'id' )
                ->label( 'code' )
                ->label( 'name' )
            )
            ->validator( Validate::notEmpty( ValidateOptions::inst()
                ->message( 'Please select supersector ..' )
            ) )
        ,Field::inst( 'dm_stocks_supersectors.code' )
        ,Field::inst( 'dm_stocks_supersectors.name' )
        
        ,Field::inst( 'dm_stocks.sector_id' )
            ->options( Options::inst()
                ->table( 'dm_stocks_sectors' )
                ->value( 'id' )
                ->label( 'code' )
                ->label( 'name' )
            )
            ->validator( Validate::notEmpty( ValidateOptions::inst()
                ->message( 'Please select sector ..' )
            ) )![](https://datatables.net/forums/uploads/editor/76/cmhbr5ibeszb.png "")

        ,Field::inst( 'dm_stocks_sectors.code' )
        ,Field::inst( 'dm_stocks_sectors.name' )

....etc

->leftJoin( 'dm_stocks_industry', 'dm_stocks_industry.id', '=', 'dm_stocks.industry_id' )
->leftJoin( 'dm_stocks_supersectors', 'dm_stocks_supersectors.id', '=', 'dm_stocks.supersector_id' )
->leftJoin( 'dm_stocks_sectors', 'dm_stocks_sectors.id', '=', 'dm_stocks.sector_id' )

...etc

you can see the problem demonstrated here, I can PM access to my system, if you have not already received the information or need it again.

https://www.dividendview.co.uk/stocks/

Search MYI, you will see once you EDIT the row the industry, supersector values change.

Values shown before an EDIT

After selecting EDIT

any help much appreciated as I have run out of ideas why this might be happening.

Best regards

Colin

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,214Questions: 1Answers: 10,415 Site admin
    Answer ✓

    Hi Colin,

    I'm getting You must be logged in to view this content. on the page when logging in with the site password you've sent me before. Possibly just that user needs permissions added?

    Thanks,
    Allan

  • cpshartcpshart Posts: 246Questions: 49Answers: 5

    Hi Allan

    I have sent you a PM with access details, with thanks.

    Best Regards
    Colin

This discussion has been closed.