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

How to reflect changes in the database to DayPilotCalendar using callback.

Asked by harshad jadhav
9 years ago.

Hello All,

I have two adjustent DayPilotCalendar controls. one for appointment list and other is for waiting list.

In the database, I have a table called appointment. In that we have field IsConfirm, It has two values 0 for appointment, 1 for waiting. Based on this I am binding the records to both controls.

while the event is rendering on the in the page i put image in the event box in following manner. and i want a particular functionality on that image click.

protected void DayPilotCalendar1_BeforeEventRender(object sender, BeforeEventRenderEventArgs e)
{
e.InnerHTML = "<img src='images/blank.gif' onclick=abc('Done',"
+ e.Tag["appointmentid"].ToString() + "); width=10px height=10px style='background-color:Red'/>";
}
onclick i am calling javascript function abc(status,Value);

Now in abc() function in javascript is written in following.

function abc(command, number) {
dpc2.commandCallBack(command, { id: number });
dpc1.commandCallBack(command, { id: number });
}

It is going to server side and calling DayPilotCalendar2_Command, DayPilotCalendar1_Command

in DayPilotCalendar2_Command i take the command name and id

protected void DayPilotCalendar2_Command(object sender, DayPilot.Web.Ui.Events.CommandEventArgs e)
{
switch (e.Command)
{
case "Done":
string id = (string)e.Data["id"];
// I take value of id and update isconfirm to 1 so ti will go to waiting
break;
}
// I bind the data to the Control and updating the control.
DayPilotCalendar2.Update(CallBackUpdateType.Full);
}

protected void DayPilotCalendar1_Command(object sender, DayPilot.Web.Ui.Events.CommandEventArgs e)
{
// I bind the data to the Control and updating the control.
DayPilotCalendar1.Update(CallBackUpdateType.Full);
}

The value is changed in the database but the DayPilotCalendar values and not changing.

for more clearfication have a look at attatched image.

Thanks and Regards
Harshad Jadhav

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

It looks like you aren't reloading the data in the server-side event handler.

You have two controls, with ClientObjectName values of "dpc1" and "dpc2".

If you want to refresh both of them, call:

dpc1.commandCallBack("refresh");
dpc2.commandCallBack("refresh");

On the server side, you need to handle Command event and reload the data (an example for one of the controls):

    protected void DayPilotCalendar1_Command(object sender, CommandEventArgs e)
    {
        switch (e.Command)
        {
            case "refresh":
                DayPilotCalendar1.DataSource = yourDataDource;
                DayPilotCalendar1.DataBind();
                DayPilotCalendar1.Update();
                break;
        }
    }

This is important:

                DayPilotCalendar1.DataSource = yourDataDource;
                DayPilotCalendar1.DataBind();

Please let me know if it didn't help.

Comment posted by Anonymous
9 years ago.

Hi Dan

Its not working. if you have any example please give it me.

Thanks and Regards,
Harshad Jadhav

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