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.
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
Please check this example Link
https://test.assettrack.cx/elevators/ele1.php
I'm getting this error back from the server when I try to load your page at the moment:
Allan
@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..
@allan now error is gone.. but still its loading .. and not updating or displaying any errors..
@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.