Populating Lightbox-Select from Server doesn`t work

Hi,

I am new to the Scheduler and I´m trying different things at the moment. I want to dynamicaly update the Options of a select box, but I can´t get it to work.

Here is the code for the lightbox:

scheduler.config.lightbox.sections = [
{ name:“text”, height:50, map_to:“text”, type:“textarea”, focus:true },
{ name:“type”, height:40, map_to:“type”, type:“select”, options:scheduler.serverList(“type”)},
{ name:“time”, height:72, type:“time”, map_to:“auto”}
];

And here ist the XML I get from the server-side-code:

2010-01-06 03:30:00 2010-01-06 06:35:00 SiS Dortmund 1 2010-01-16 10:00:00 2010-01-16 10:05:00 Markus Berg 1 2010-01-10 13:50:00 2010-01-10 18:00:00 Markus Berg 2 2010-01-10 10:00:00 2010-01-10 15:05:00 Hans Werner 3 2010-01-10 10:00:00 2010-01-10 15:15:00 Markus Berg 4 2010-01-10 14:55:00 2010-01-10 18:00:00 Hans Peter 5 2010-01-11 10:00:00 2010-01-11 18:00:00 Markus Mueller 3 2010-01-12 09:50:00 2010-01-12 18:00:00 Markus Meier 6 2010-01-12 10:00:00 2010-01-12 18:00:00 Hans Meiser 1

So the Options are correctly defined in the XML. But in the Lightbox I get four times a “null”. What am I doing wrong?

Another Question: I want to use my own specific SQL-Query to get the Options out of my Database. How can I do this?

Kind Regards,

Sebastian

Hello,
please check the working example
docs.dhtmlx.com/scheduler/sample … tions.html
The correct definition of options requires ‘value’ and ‘label’ attributes docs.dhtmlx.com/scheduler/sample … 8381029945

Please specify what do you use on the server

Thanks for the reply. I was able to fix the first Problem. I´m working on the second question now. I use php. I understood, that i can use the Query-String instead of the table-name, but that doesn´t work at the Moment. I will try a bit.

Thanks for your help.

Sebix

So I have tried out some things now, but I can´t find my mistake.

I just replaced the table “units” with "SELECT * FROM units.

Now in php it looks like this:

$list->render_table("select * FROM units",“id”,“unit_name”,“id(value),unit_name(label)”);

I also tried it with render_sql.

It doesn´t work.

Here is the XML I get:

<coll_options for=‘type’>



</coll_options>

( => it´s a double ', not a single ")

Using the Table-Name works:

$list->render_table(“units”,“id”,“unit_name”,“id(value),unit_name(label)”);

It´s the same result in SQL, so there shouldn´t be a difference.

Where is my mistake? Any Ideas?

Sebix.

UPDATE:

Hi!

Now after a little testing I found the mistake and it works now. But I have the next Problem. :astonished:

The select-element in the lightbox has to be updated every time before it is opened. I tried the “onBeforeLightbox” and “onEmptyClick” event. The select-element-content is updated, but to late, the lightbox is allready open. The next time I open it, the correct values are displayed… for the last one.

Is there any way to update the select-content while the lightbox is open or to wait for the “load”-Method to finish until the lightbox opens?

My next Idea was to preload the data for the select element and store it in an array of Arrays and then use the updateCollection-Method within the onBeforeLightbox-Event like this:

scheduler.updateCollection(“type”, alert_opts2);

Here the Definition of alert_opt2:

var alert_opts2 = [
{ key: 1, label: ‘Neu’ },
{ key: 2, label: ‘Ganz Neu’ },
{ key: 3, label: ‘SuperNeu’ }
];

But the content of the select-element is not updated, even after calling

scheduler.resetLightbox();

and reopening the lightbox.

Kind Regards,
Sebix

If you already have some kind of logic for select reloading, just be sure that you are calling scheduler.resetLightbox() ( it will close the currently active lightbox, so you will need to use showLightbox after that )

Maybe a bit better solution would be to use formSection API, it gives you access to the HTML element of the rendered select box control in the lightbox. You can replace old options with new onew directly in the HTML

docs.dhtmlx.com/scheduler/api__s … ction.html