search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

events empty

Asked by Esperanza
6 years ago.

help please, not show all events, just 12 of 70 events. first add node --->dp.resources.push this works fine, second
add events but just add 12 events.... then show console ---->alert(dp.events.list[g].resource + " - " + dp.events.list[g].text + " - " + g); and it show all events but in the schedule not see all what can I do?

$('#dp').val("");

dp.startDate = $('#hiden_inicio').val();
dp.days = 366;
dp.scale = "Day";
dp.timeHeaders = [
{ groupBy: "Month", format: "MMM yyyy" },
{ groupBy: "Cell", format: "d" }
];
dp.dragOutAllowed = false;
dp.allowMultiSelect = false;
dp.bubble = new DayPilot.Bubble();
dp.resourceBubble = new DayPilot.Bubble();
dp.rowHeaderColumns = [
{ title: 'Actividades', width: 150 }
];
dp.treeEnabled = true;
dp.rowHeaderScrolling = true;
dp.autoWidth = true;
dp.progressiveRowRendering = false;
dp.resources = [];
dp.update();
dp.heightSpec = "Max";
dp.dynamicLoading = true;
dp.durationBarVisible = true;
dp.durationBarMode = "PercentComplete";
dp.events.list = [];
dp.update();
$.ajax({
url: "../../Handler.ashx?tip=areagroup&ip=" + $('#id_proy_tab').val(),
contentType: 'application/text; charset=utf-8',
type: "POST",
cache: false,
async: true,
dataType: "text",
success: function (json) {
var datamk = json.split('|');
obj = JSON.parse(datamk[1]);

// alert(obj.length);
for (var i = 0; i < obj.length; i++) //The json object has lenght
{
dp.resources.push({ name: obj[i].area + " - " + obj[i].seccion, id:"a"+ obj[i].id });

}
dp.update();
for (var g = 0; g < obj.length; g++) //The json object has lenght
{

e = {
start: $('#hiden_inicio').val(),
end: $('#hiden_ffin').val(),
id: DayPilot.guid(),
text: obj[g].seccion,
resource: "a"+obj[g].id,
moveVDisabled: true,
moveHDisabled: true,
complete: 20
};
dp.events.list.push(e);
alert(dp.events.list[g].resource + " - " + dp.events.list[g].text + " - " + g);
}

dp.update();
// dp.events.add(e);

},
error: function (jqXHR, exception) {

alert("Error al Consultar !!");
}
});

dp.eventMovingStartEndEnabled = false;
dp.eventResizingStartEndEnabled = false;
dp.timeRangeSelectingStartEndEnabled = false;

dp.init();

dp.scrollTo($('#hiden_ffin').val());

Answer posted by Dan Letecky [DayPilot]
6 years ago.

It looks like you are calling the .update() method too much. The update() is performed asynchronously a multiple simultaneous calls may disrupt the display.

  • It's not necessary to call .update() before or right after .init().
  • Only call .update() when you make any changes to the Schedule config.
  • When changing multiple things (resources, events, config) call .update() just once at the end.

Schematically, it should look like this:

var dp = new DayPilot.Scheduler("dp");
// ... your config here, no .update() calls
dp.init();

loadEventsAndResources();

function loadEventsAndResources() {
  $.ajax(... function(result) {
   dp.events.list = /* ... */ ;
   dp.resources = /* ... */ ;
   dp.update(); // just once after applying all changes
  });
}

Also, keep in mind that the resource id must match the event.resource property exactly. It must be the same type (number/number, string/string) and in case of strings it must be exactly the same string (no case differences, no extra spaces). The values are compared using '===' operator. If the event.resource value doesn't match any resource.id it will not be displayed.

This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.