Not loading combo

Hi,

I have this agenda and aluno table as follow:

I’m trying to load this into the scheduler and the lightbox, but is not working.

The carregarAlunos.php is working, returning an xml with the right info

[code]<?php
require_once(‘…/…/dao/scheduler/connector/combo_connector.php’);

// Mysql
$dbtype = “MySQL”;
$res=mysql_connect(“localhost”, “root”, “”);
mysql_select_db(“sam”);

$combo = new ComboConnector($res, $dbtype);

$combo->event->attach(“beforeFilter”, “by_id”);
function by_id($filter) {
if (isset($_GET[‘id’]))
$filter->add(“id”, $_GET[‘id’], ‘=’);
}

$combo->dynamic_loading(3);
$combo->render_table(“aluno”,“id”,“nome”);
?>[/code]

The script from index.html:

<script>
        function init() {
            scheduler.config.xml_date="%Y-%m-%d %H:%i";
            scheduler.config.prevent_cache = true;
            scheduler.config.details_on_create = true;
            scheduler.config.details_on_dblclick = true;
            scheduler.locale.labels.section_type = "Aluno:";
            scheduler.locale.labels.section_time = "Horário: ";
            scheduler.locale.labels.section_description = "Aluno: ";
            scheduler.config.event_duration = 45;

            var holders = [
                { key: 1, label: 'James' },
                { key: 2, label: 'Alex' },
                { key: 3, label: 'Antony' },
                { key: 4, label: 'Andrew' }
            ];
            scheduler.locale.labels.section_holder = "Holder";

            scheduler.config.lightbox.sections=[
                //{name:"description", height:130, map_to:"text", type:"textarea" , focus:true},
                { name:"holders", options:holders, map_to:"holders", type:"combo",
                    image_path:"../../script/scheduler/dhtmlxCombo/imgs/", height:30, filtering:true, script_path: "carregarAlunos.php"},
                {name:"type", map_to:"idaluno", type:"select", options:scheduler.serverList("aluno")},
                {name:"time", height:72, type:"time", map_to:"auto"}
            ]
            scheduler.config.first_hour=6;

            scheduler.init('scheduler_here', new Date(),"day");
            scheduler.setLoadMode("day");
            scheduler.load("carregarAgenda.php");

            var dp = new dataProcessor("carregarAgenda.php");
            dp.init(scheduler);
        }
    </script>

My idea is load the field nome as a combobox into the agenda table.

How much records do you have in aluno table ?
If it less than 50 - it has sense to load them all at once without using filtering or dyn. loading.

Combo in the scheduler can work in two modes

  • load all records at once, and filter as user types something in combo input
  • load records dynamically, as user types something in combo input

But combo is not purposed to show different sets of properties for different events.

The combo is loading correctly, now I have another problem… :blush:

The combo is loading, but is not loading the selected option.

I followed the joining tables example here: http://docs.dhtmlx.com/doku.php?id=dhtmlxconnector:basis#work_with_several_tables

[code]<?php
include (’…/…/dao/Connection.php’);
include (’…/…/dao/scheduler/connector/db_mysqli.php’);
include (’…/…/dao/scheduler/connector/scheduler_connector.php’);

// MySQL
$dbtype = “MySQL”;
$res=mysql_connect(“localhost”, “root”, “”);
mysql_select_db(“sam”);

$details = new JSONDataConnector($res);
$details->configure(“aluno”,“id”,“nome, telefone_res”);

$calendario = new JSONSchedulerConnector($res, $dbtype);
$calendario->mix(“aluno”, $details, array(
“id” => “idaluno”
));

$calendario->render_sql(“SELECT * FROM agenda”, “id”,“inicio,fim,idaluno”, “”,"");

?>[/code]

it is returning the JSON:

{ "data":[{"id":"2","start_date":"2013-11-05 05:00:00","end_date":"2013-11-05 06:00:00","text":"2","aluno":{"id":"2","nome":"Stevie Wozniak","telefone_res":null}}]}

Now I’m trying to put into the field at scheduler the field nome from aluno.

scheduler.config.lightbox.sections=[ { name:"alunos", options:alunos, map_to:"idaluno", type:"combo", cache: false, image_path:"../../scripts/scheduler/dhtmlxCombo/imgs/", height:30, filtering:true, script_path: "carregarAlunos.php"}, {name:"time", height:72, type:"time", map_to:"auto"}]

But I don’t know how to.

While you can use mix to generate a complex data sets, the lightbox configuration can’t load data from nested objects. You can use onAfterLightbox event handler from which set the necessary data by custom code

var id = scheduler.getState().lightbox_id; var name = scheduler.getEvent(id).aluno.nome; scheduler.formSection('alunos').setValue(name);

I tried the above code, but I got null from:

var id = scheduler.getState().lightbox_id;

Dunno why. Any suggestion?

Thanks.

Sorry for inconvenience, was a my mistake.
Please use onLightbox event for the above code, not the onAfterLightbox