UpdateCollections with ServerList set does not work

We’re using Scheduler .NET with MVC 5 and are trying to update the timeline view with no luck.

In the create view controller action:

var timeline = new TimelineView("myTimeline", "vehicle_id"); timeline.ServerList = "myTimeline_options";

In the view:

$.getJSON("../../TrafficJournal/Sections", function (data) {
            scheduler.updateCollection("myTimeline_options", data);
        });

We tried to put dummy data as well but it didn’t work.

scheduler.updateCollection("myTimeline_options", [{ key: "1", label: "John" }, { key: "2", label: "Adam" }, { key: "3", label: "Diane" }]);

No error message, nothing happens, what are we missing? Any suggestions?

Hi,
can you attach a demo which reproduces the problem?

I think i’ve used the very same code what you provided and everything seems work correctly. The project is attached (you’ll need to restore nuget packages)
The demo loads a dummy sections into the timeline after some timeout
SchedulerNET.ServerList.zip (247 KB)

Thanks for the reply. I tried your example and it worked. But if I modify it like this it doesn’t update the timeline anymore. Is it the wrong way to do it?

public ActionResult Index()
        {
            //Being initialized in that way, scheduler will use CalendarController.Data as a the datasource and CalendarController.Save to process changes
            var scheduler = new DHXScheduler(this);
            scheduler.InitialDate = new DateTime(2012, 09, 03);

            var vehicleList = new List<Vehicle>();
            var vehicle1 = new Vehicle() { key = "1", label = "Vehicle 1" };
            vehicleList.Add(vehicle1);
            var vehicle2 = new Vehicle() { key = "2", label = "Vehicle 2" };
            vehicleList.Add(vehicle2);
            var vehicle3 = new Vehicle() { key = "3", label = "Vehicle 3" };
            vehicleList.Add(vehicle3);

            var timeline = new TimelineView("myTimeline", "vehicle_id");
            timeline.ServerList = "myTimeline_options";
            timeline.AddOptions(vehicleList);

            scheduler.Views.Add(timeline);
            scheduler.LoadData = true;
           // scheduler.EnableDataprocessor = true;
            scheduler.InitialView = timeline.Name;
            return View(scheduler);
        }

And then in the view I have:

<a href="javascript:updateTimeline();">Update timeline</a>
function updateTimeline() {
            scheduler.updateCollection("myTimeline_options", [
                   { key: "1", label: "New name" },
                   { key: "2", label: "Other name" },
                   { key: "3", label: "changed" }
            ]);
        }

Solved! ServerList must be set after AddOptions, otherwise it gets some generated name.

var timeline = new TimelineView("myTimeline", "vehicle_id");
timeline.AddOptions(vehicleList);
timeline.ServerList = "myTimeline_options";

OK, too fast, if I set the ServerList name the events don’t show. I had to do this:

var timeline = new TimelineView("myTimeline", "vehicle_id");
timeline.AddOptions(vehicleList);
 //timeline.ServerList = "myTimeline_options"; // DO NOT SET
function updateTimeline() {
        $.getJSON("../../TrafficJournal/Sections", function (data) {
            var serverList = scheduler.config.serverLists["myTimeline"];
            scheduler.updateCollection(serverList, data);
        });
    }

Thanks for details! We’ll correct this behavior in nearest update, the assigned Timeline.ServerList should not create an issue with loaded options