Getting y_unit values in Timeline view.

Hello,

I am trying to get the values for the sections in the timeline view from my database. I have gone over the samples and the forum and I seem to be missing something. I can get it to return something from the database however it is in the wrong format and is not showing up in the schedule.

Here is my JS:

[code] var sections = scheduler.serverList(“sections”);

scheduler.createTimelineView({
    name:	"timeline",
    x_unit:	"minute",
    x_date:	"%H:%i",
    x_step:	60,
    x_size: 12,
    x_start: 8,
    x_length:	24,
    y_unit:	sections,
    y_property:	"ID",
    render:"bar"
});

scheduler.init('scheduler_here', null, "timeline");

scheduler.load("/schedule/connector.php");

[/code]

And my PHP:

        $options = new PWPSchedulerOptionsConnector();
        $DataFields = "USRUsers.ID as ID, concat(PPLPeople.FirstName, ' ', PPLPeople.LastName) as label";
        $SQL = "SELECT $DataFields from USRUsers JOIN PPLPeople on USRUsers.PPLPeople_ID = PPLPeople.ID where USRUsers.IsActive = 1";

        $options->render_sql($SQL, "ID", "ID, label");
        $scheduler->set_options("sections",$options);

The response from my server is:

{ "data":[], "collections": {"sections":[<item ID='1' label='jess b'><\/item>\n]}}

which doesn’t look right to me. How can I get it to show up along the side as the sections in timeline view? I need to be able to schedule tasks per employee. What am I missing? Any pointers would be greatly appreciated.

Thank you!

Hi,
you need to use JSONOptionsConnector
check following files from scheduler package
samples/01_initialization_loading/11_connector_options_json.html
samples/01_initialization_loading/data/types_json.php
in this example connector is used to load ligthbox options, but it will also work for timeline sections

Thank you! That definitely helped since I was using the wrong Connector.

However, I am still having an issue with my render_sql.

[code] $DataFields = “USRUsers.ID as ID, concat(PPLPeople.FirstName, ’ ', PPLPeople.LastName) as name”;
$SQL = “SELECT $DataFields from USRUsers JOIN PPLPeople on USRUsers.PPLPeople_ID = PPLPeople.ID where USRUsers.IsActive = 1”;

    $options->render_sql($SQL, "ID", "ID(value),name(label)");[/code]

This is returning:

{ "data":[], "collections": {"sections":[{"id":"1","value":null,"label":null}]}}

So my resources are showing up as “null”. I’m pretty sure it has something to do with my render_sql but I am not sure how to fix it. I have tried a variety of combinations for the fields parameter but nothing seems to be working. Can you please point me in the right direction? Thank you!

change

    $DataFields = "USRUsers.ID as ID, concat(PPLPeople.FirstName, ' ', PPLPeople.LastName) as name";

as

    $DataFields = "USRUsers.ID as value, concat(PPLPeople.FirstName, ' ', PPLPeople.LastName) as label";

When using render SQL, and wanting to apply aliases, you need to alias that fields in SQL as well.

Thank you! That worked.