Dropdown values in Editor not updating. Showing some loading bars and editor stop working.

Dropdown values in Editor not updating. Showing some loading bars and editor stop working.

Shivani VyasShivani Vyas Posts: 113Questions: 11Answers: 0

Hello here is my example:
https://test.assettrack.cx/elevators/ele1.php

In above example > In editor.. There are two dropdowns.. Location and Drawing ID. Location Dropdown is working fine. The second Dropdown Drawing ID is dependent on Location. It will display Drawing ID for particular Location selected by user.

For e.g. If user select Location > Avenue.. Drawing ID Dropdown will display Avenue's Drawing IDs.

I used "editor dependent " to develop this functionality. But when I try to update location and DrawingID editor stops working and not updating dropdown values.. Also its displaying some weird loading bars besides Location dropdown.. Please have a look by assessing above page link and try to edit location / Drawing Id dropdowns.

> Here is my dependent code..

editor.dependent( 'Location', function(val){

      $.getJSON("../ajax/at/elevDwgTagList.php",
                     {
                        location: val
                     },
                     function (data) {
                        editor.field('DrawingID').update(data);

                    }
                 );
  });

**> Here is sql query **

<?php
include_once("../lib/DataTables.php");

    $asset = $db
        ->select(
            'asset', 
            [
            'id as value', 
            'dwgTag as label'
            ], 
            function ($q) {
            $q
                ->where(function ($r) {
                    $r->where('assetType', 1);
                    $r->or_where('assetType', 2);
                  })
                ->where('loc', $_GET['location']);

            }
        )
        ->fetchAll();

 echo json_encode( $asset );
// echo json_encode( [
//     'options' => [
//         'DrawingID' => $asset,
//     ]
// ] );
?>

**> Here is controller code **

Field::inst( 'A.id', 'DrawingID') // To display Drawing ID Dropdown in Edit form
        ->options( Options::inst()
            ->table('asset')
            ->value('id')
            ->label('dwgTag')
            ->where( function ($q) {
                $q->where( 'id', 0, '!=' );
                $q->and_where(function ($r) {

                            $r->where('assetType', 1);
                            $r->or_where('assetType', 2);
                        });

            } )
            ->order('id')
            )
        // ->validator( Validate::dbValues() )
        ->validator( Validate::notEmpty( ValidateOptions::inst()
        ->message( 'Which Drawing ID are we updating?' )
        )),

    Field::inst( 'A.dwgTag', 'dwgTag'), // to display Drawing ID in grid

Replies

  • Shivani VyasShivani Vyas Posts: 113Questions: 11Answers: 0

    Please check this example Link

    https://test.assettrack.cx/elevators/ele1.php

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin

    I'm getting this error back from the server when I try to load your page at the moment:

    Fatal error: Uncaught Error: Call to a member function dbField() on null in /chroot/home/assettrack/test.assettrack.cx/html/ajax/lib/Editor.php:2347 Stack trace: #0 /chroot/home/assettrack/test.assettrack.cx/html/ajax/lib/Editor.php(972): DataTables\Editor->_prepJoin() #1 /chroot/home/assettrack/test.assettrack.cx/html/ajax/lib/Editor.php(701): DataTables\Editor->_process() #2 /chroot/home/assettrack/test.assettrack.cx/html/ajax/at/elevators.php(531): DataTables\Editor->process() #3 {main} thrown in /chroot/home/assettrack/test.assettrack.cx/html/ajax/lib/Editor.php on line 2347

    Allan

  • Shivani VyasShivani Vyas Posts: 113Questions: 11Answers: 0

    @allan I am not sure how you got these errors.. I made page public.. I am able to access it but dont know why its not accessible for you.

    I got this error when I try to update in editor..


  • Shivani VyasShivani Vyas Posts: 113Questions: 11Answers: 0

    @allan now error is gone.. but still its loading .. and not updating or displaying any errors..

  • Shivani VyasShivani Vyas Posts: 113Questions: 11Answers: 0

    @allan Thank you allan for your help. Issue has been resolved. There was a mistake in my code.. I was binding dropdown with wrong column reference , also there was some syntax issue in my sql file.. I updated my code as below and it working fine.

    <?php
    include_once("../lib/DataTables.php");
    
        $asset = $db
            ->select(
                'asset', 
                [
                'id as value', 
                'dwgTag as label'
                ], 
                function ($q) {
                $q
                    ->where(function ($r) {
                        $r->where('assetType', 1);
                        $r->or_where('assetType', 2);
                      })
                    ->where('loc', $_REQUEST['values']['Location']);
    
                }
            )
            ->fetchAll();
    
    //echo json_encode( $asset );
    echo json_encode( [
        'options' => [
            'DrawingID' => $asset,
        ]
    ] );
    ?>
    
Sign In or Register to comment.