Multiselect example - getEvent doesn't get multiselect value

In the multiselect example, there are a list of fruit which can be selected.

If I double click on the event, edit it, and press save, I can run scheduler.getEvent(ID) on it, and there will be a property ‘fruit_id’ which contains a comma separated string of the fruit ids.
However, if I haven’t yet double clicked on the event, scheduler.getEvent(ID) doesn’t contain that ‘fruit_id’ property, even though it does contain all of the other properties such as ‘description’.

Why is this, and how can I change it so that fruit_id is automatically loaded?

Sample database table does not have column for ‘fruit_id’ propertie, so the property appears only after it’s assigned by the lightbox. If you create such column and add it into connectors configuration, it will be loaded initially

But it stores the fruits related to that event in the ‘event_fruit’ table, and by adding a ‘fruit_id’ column in the ‘event’ table, that would cause data duplication, and is therefore more prone to mistakes.

Is there any way to get a list of all of the fruit attached to an event without having to open the edit form (and if possible, without having to make another database call, as that can be quite slow - if that’s the only option, I’ll use that though).

check following example,
it loads all needed data initially
scheduler/samples/03_extensions/22_multiselect_initial_loading.html

There different data relations.
If you have “one to one” relation - you can add extra field to events table
If you have “many to many” relation - you need to have more complex design ( table for events, table for object and table for links between them )

In second case there are 2 strategy to fetch data
a) collect all data and load at once - which may require a lot of DB queries
b) load data on demand

When you are using multi-selects in scheduler you can chose (a) or (b) solution

(a) - samples\03_extensions\data\events_multiselect_static.php
(b) - samples\03_extensions\data\events_multiselect_options.php

In case of (a) solution - all options will be available on client side and will be accessible by js api.

Thanks for the reply.

If I do ‘b’ (load data on demand), is there an API call that I can use to load the multiselect data without opening the edit box?

Currently it is not possible, data loading is a part of lightbox rendering and can’t be called separately.

Something like next can be used
Here config.property need to be replaced with config setting of multiselect

[code]dhtmlxAjax.get(config.script_url + ‘?dhx_crosslink_’ + config.map_to + ‘=’ + ev.id, function(loader) {
var _result = loader.doXPath("//data/item");
var _ids = [];
for (var i = 0; i < _result.length; i++) {
_ids[_result[i].getAttribute(config.map_to)] = true;
}

    //ids - array of ids

});[/code]

Thanks sooooo much!

You don’t know how much that has helped!
The system is now so much quicker to run!

Thanks :slight_smile: