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

How to Refresh DayPilot Lite Scheduler after entering event

Asked by Anonymous
8 years ago.

I am using the modal window to add data into database and required a refresh on the scheduler after that. I am referring to another post in this forum and write my code as this

[in the scheduler page javascript]
modal.closed = function () {
if (this.result && this.result.refresh) {
__doPostBack(id.refreshButton, '');
}
and

[ hidden refresh button]
<div style="display:none">
<asp:Button id="ButtonRefresh" runat="server" OnClick="ButtonRefresh_Click" />
</div>

[code behind]
protected void ButtonRefresh_Click(object sender, EventArgs e)
{
LoadResourcesAndEvents();
}

[in the add page code behind]
//insert into database code....
Hashtable ht = new Hashtable();
ht["refresh"] = "yes";
Modal.Close(this,ht);
but i get this error in "DataItem doesn't hold any source object." in my DayPilotScheduler1_BeforeEventRender.
Please help.

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

This happens because you access e.DataItem in your BeforeEventRender event handler but you don't load the events using DataBind() during the PostBack (ButtonRefresh_Click). The events are loaded from the ViewState but the ViewState doesn't allow restoring the source object (e.DataItem) - it is null.

You need to reload the events in ButtonRefresh_Click using DayPilotScheduler.DataBind().

In the Pro version you can also replace e.DataItem with e.Tag["field"] (specify the tag fields using DataTagFields property).

See also:
http://doc.daypilot.org/scheduler/event-customization/

Example:

<DayPilot:DayPilotScheduler
  ...
  DataTagFields="detail, color"
/>

protected void DayPilotScheduler1_BeforeEventRender(object sender, BeforeEventRenderEventArgs e)
{
  e.BubbleHtml = e.Tag["detail"];
  e.BackgroundColor = e.Tag["color"];
}
Comment posted by Anonymous
8 years ago.

But in the LoadResourcesAndEvents() inside the button refresh click already contain the bind()...
this is my code in LoadResourcesAndEvents()
private void LoadResourcesAndEvents()
{
LoadResources();
DayPilotScheduler1.DataSource = DbGetEvents(DayPilotScheduler1.StartDate, DayPilotScheduler1.EndDate);
DayPilotScheduler1.DataBind();
}

Comment posted by Anonymous
8 years ago.

after trying many times.. i finally managed to refresh the scheduler.. it wont refresh because i missed out some codding..thanks for your help

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