dynamical section(timeline y_unit)

hi,

i want to implement dhtmlx scheduler with timline in our rails application.

we want to load the section from the db.

can i load the section like the ‘events’?

controller:

def records
    @records = Mainplan.all

    respond_to do |format|
      format.xml
    end
  end

records.xml.builder:

xml.instruct! :xml, :version=>"1.0"

xml.tag!("data") do #actual count of records need to be used here
  @records.each do |record|
    xml.tag!("event",{ "id" => record.id }) do
      xml.tag!("text", record.note)
      xml.tag!("start_date", record.datum)
      xml.tag!("end_date", record.datum_end)
      xml.tag!("section_id", [i]SomeTableCall.find.id[/i])
    end
  end
end

show.html.erb

....
        scheduler.init('scheduler_here',new Date(),"timeline");
        scheduler.load("/records");

That part is working fine.

Know i want the same for the section:

controller:

def sections
    @sections= Mainplan.all

    respond_to do |format|
      format.xml
    end
  end

sections.xml.builder:

xml.instruct! :xml, :version=>"1.0"

xml.tag!("data") do #actual count of records need to be used here
  @sections.each do |section|
    xml.tag!("sections",{ "id" => section.id }) do
      xml.tag!("key", section.id)
      xml.tag!("label", section.note)
    end
  end
end

show.html.erb

....
scheduler.load("sections");
var sections = [
   ??
]

please help me :frowning:

or how can i hide sections with no input in x-unit?

You can form xml like

[code]
… events info here…

<coll_options for=“sections”>



</coll_options>
[/code]

And on client side you can use

var sections = scheduler.serverList("sections");
scheduler.load("data.url", function(){
   //now you have data in sections array
   alert(sections.length); //3
});

hm… is not working :frowning:

is not even jumping in the function to fire the alert.

do you have some advice?

but its going through the sections.xml.

ok, now die alert is fireing :slight_smile:

i had to move the function call after the scheduler.init.

because with the section its not working,
i try something like this with my event data.

        scheduler.init('scheduler_here',new Date("2013.07.04"),"timeline");


        scheduler.load("/records", function() {
            var event = scheduler.serverList(foo);
            alert("records" + event.length);
        });

why its always shows me a length from 0?
the data is loading correct in the scheduler

sry, of course

        scheduler.init('scheduler_here',new Date("2013.07.04"),"timeline");


        scheduler.load("/records", function() {
            var event = scheduler.serverList("event");
            alert("records" + event.length);
        });

ok is working now:

       var sections = scheduler.serverList("sections", scheduler.load("sections.xml"));

the .xml was missing…