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

JavaScript Error when I add an event.

Asked by peter cli
17 years ago.

Error : Microsoft JScript runtime error: 'rows[...].cells' is null or not an object

I am using DayPilot Pro 4.0.1205.1

Here is my code :

hc.InsertEvents("new event", e.Start, e.End, Convert.ToInt32(e.ColumnId), false, Page.User.Identity.Name);
DayPilotScheduler1.DataSource = hc.GetEvents();
DayPilotScheduler1.DataBind();
DayPilotScheduler1.Update();

Comment posted by Dan Letecky
17 years ago.
Thanks for reporting the bug.

Could you please send me your .aspx and aspx.cs files to daypilot @ annpoint.com? I would like to test it with your code because it doesn't appear in the demo.
Comment posted by Dan Letecky
17 years ago.
This error was caused by the following code:
    protected void Page_Load(object sender, EventArgs e)
{
DayPilotScheduler1.Resources.Add("One", "1");
DayPilotScheduler1.Resources.Add("Two", "2");
DayPilotScheduler1.Resources.Add("Three", "3");

DayPilotScheduler1.DataSource = getEvents();
DataBind();
}

The Resources collection is persisted across requests using ViewState and calling this code during PostBack requests adds the resources again to the collection. The internal event-arranging code works with an updated Resources collection (with doubled items) but the client-side code works with the original collection (CallBack action is not able to update the Resources collection, only the events). The Resources initialization code should be put it inside "if (!IsPostBack)" block:

    protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DayPilotScheduler1.Resources.Add("One", "1");
DayPilotScheduler1.Resources.Add("Two", "2");
DayPilotScheduler1.Resources.Add("Three", "3");

// having the following two lines outside of the conditional block
// will not produce an error but it will mean extra database
// lookup
DayPilotScheduler1.DataSource = getEvents();
DataBind();
}
}

I've made changes to DayPilot code that will prevent this JavaScript error even if you extend the Resources collection during callback.

But remember that if an existing Resources collection item is changed during callback (e.g. if item "Two" is replaced with "Four") it will still confuse the client during update.

Comment posted by Dan Letecky
17 years ago.
And, the fix will be included in 4.1 release.
This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.