PDA

View Full Version : [CLOSED] Calendarpanel refresh issue + objectdatasource



bossun
Aug 08, 2012, 3:06 PM
Hi,

I have a refresh issue with the calendarpanel. When I add/edit an event, I need to refresh the whole page to see my changes. My calendarpanel is fed by a objectdatasource and I use directeEvents to store data. In the 1.x DataBind() worket fine but in 2.0 no cussess.

Here is my Code :



<body>
<form id="form1" runat="server">
<ext:ResourceManager
runat="server"
Namespace="CompanyX"
/>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
SelectMethod="CalendarRead"
TypeName="Sigmasport.Code.BusinessLayer.SigmaSportCalendar">
<SelectParameters>
<asp:ProfileParameter Name="UserId" PropertyName="UserId" Type="Int32" />
</SelectParameters>
</asp:ObjectDataSource>
<ext:Viewport ID="Viewport1" runat="server" Layout="Border">
<Items>
<ext:Panel ID="Panel1"
runat="server"
Border="false"
Region="North"
>
</ext:Panel>

<ext:Panel
ID="Panel2"
runat="server"
Title="<%$ Resources:Resource,Calendar %>"
Layout="Border"
Region="Center"
Cls="app-center">
<Items>
<ext:Panel ID="Panel3"
runat="server"
Width="186"
Region="West"
Border="false"
Cls="app-west"
>
<Items>
<ext:DatePicker
ID="DatePicker1"
runat="server"
TodayText="<%$ Resources:Resource,Today %>"
Cls="ext-cal-nav-picker">

<Listeners>
<Select Fn="CompanyX.setStartDate" Scope="CompanyX" />
</Listeners>
</ext:DatePicker>
</Items>
</ext:Panel>

<ext:CalendarPanel
ID="CalendarPanel1"
runat="server"
Region="Center"
ActiveIndex="2"
Border="false"
WeekText="<%$ Resources:Resource,Week %>"
DayText="<%$ Resources:Resource,Day %>"
MonthText="<%$ Resources:Resource,Month %>"
TodayText="<%$ Resources:Resource,Today %>"
>
<EventStore ID="EventStore1" runat="server" NoMappings="true" DataSourceID="ObjectDataSource1" />

<CalendarStore ID="GroupStore1" runat="server">
<Calendars>
<ext:CalendarModel CalendarId="1" Title="Holidays" />
</Calendars>
</CalendarStore>

<MonthView ID="MonthView1"
runat="server"
ShowHeader="true"
ShowWeekLinks="true"
ShowWeekNumbers="true"
/>
<Listeners>
<ViewChange Fn="CompanyX.viewChange" Scope="CompanyX" />
<EventClick Fn="CompanyX.record.show" Scope="CompanyX" />
<DayClick Fn="CompanyX.dayClick" Scope="CompanyX" />
<RangeSelect Fn="CompanyX.rangeSelect" Scope="CompanyX" />
</Listeners>
<DirectEvents>
<EventMove OnEvent="EventAdded">
<EventMask ShowMask="true" Target="CustomTarget" CustomTarget="#{CalendarPanel1}" Msg="<%$ Resources:Resource,M_Wait_Saving %>" />
<ExtraParams>
<ext:Parameter Name="Event" Value="Ext.encode(record.data)" Mode="Raw">
</ext:Parameter>
</ExtraParams>
</EventMove>
<EventResize OnEvent="EventAdded">
<EventMask ShowMask="true" Target="CustomTarget" CustomTarget="#{CalendarPanel1}" Msg="<%$ Resources:Resource,M_Wait_Saving %>" />
<ExtraParams>
<ext:Parameter Name="Event" Value="Ext.encode(record.data)" Mode="Raw">
</ext:Parameter>
</ExtraParams>
</EventResize>
</DirectEvents>
</ext:CalendarPanel>
</Items>
</ext:Panel>
</Items>
</ext:Viewport>

<ext:EventWindow
ID="EventEditWindow1"
runat="server"
Hidden="true"
CalendarStoreID="GroupStore1"
TitleTextAdd="<%$ Resources:Resource,AddNew %>"
TitleTextEdit="<%$ Resources:Resource,EditEvent %>"

>
<Listeners>
<BeforeRender Handler="
this.getDockedComponent(0).items.get(0).hidden=tru e;
dateRangeItem = this.formPanel.getComponent('date-range');
calendarItem = this.formPanel.getComponent('calendar');
dateRangeItem.fieldLabel = this.vDateRangeItem;
calendarItem.fieldLabel = this.vCalendarItem;

this.formPanel.getComponent('title').hidden = true;
calendarItem.disabled=true;
"/>
</Listeners>
<CustomConfig>
<ext:ConfigItem Name="vDateRangeItem" Value="<%$ Resources:Resource,When %>" Mode="Value" />
<ext:ConfigItem Name="vCalendarItem" Value="<%$ Resources:Resource,Calendar %>" Mode="Value" />
</CustomConfig>
<DirectEvents>
<EventAdd OnEvent="EventAdded">
<EventMask ShowMask="true" Target="CustomTarget" CustomTarget="#{CalendarPanel1}" Msg="<%$ Resources:Resource,M_Wait_Saving %>" />
<ExtraParams>
<ext:Parameter Name="Event" Value="Ext.encode(record.data)" Mode="Raw">
</ext:Parameter>
</ExtraParams>
</EventAdd>
<EventDelete OnEvent="EventDelete">
<Confirmation Message="<%$ Resources:Resource,M_Confirm_Delete %>" ConfirmRequest="true"/>
<EventMask ShowMask="true" Target="CustomTarget" CustomTarget="#{CalendarPanel1}" Msg="<%$ Resources:Resource,M_Wait_Delete %>" />
<ExtraParams>
<ext:Parameter Name="Event" Value="Ext.encode(record.data)" Mode="Raw">
</ext:Parameter>
</ExtraParams>
</EventDelete>
<EventUpdate OnEvent="EventAdded">
<EventMask ShowMask="true" Target="CustomTarget" CustomTarget="#{CalendarPanel1}" Msg="<%$ Resources:Resource,M_Wait_Saving %>" />
<ExtraParams>
<ext:Parameter Name="Event" Value="Ext.encode(record.data)" Mode="Raw"/>
</ExtraParams>
</EventUpdate>
</DirectEvents>
</ext:EventWindow >

</form>
</body>






public partial class Web_Calendar_Calendar : SigmaSportPage
{

protected void EventAdded(object sender, DirectEventArgs e)
{

Dictionary<string, object> CurrentEvent = JSON.Deserialize<Dictionary<string, object>>(e.ExtraParams["Event"]);
object BeginDate = null;
object EndDate = null;
object IsAllDay = null;
object IsNew = null;
object EventId = null;

CurrentEvent.TryGetValue("StartDate", out BeginDate);
CurrentEvent.TryGetValue("EndDate", out EndDate);
CurrentEvent.TryGetValue("IsAllDay", out IsAllDay);
CurrentEvent.TryGetValue("IsNew", out IsNew);
CurrentEvent.TryGetValue("EventId", out EventId);

if (Convert.ToBoolean(IsNew))
SigmaSportCalendar.CalendarInsert(Profile.UserId, Convert.ToDateTime(BeginDate), Convert.ToDateTime(EndDate), Convert.ToBoolean(IsAllDay));
else
SigmaSportCalendar.CalendarUpdate(Profile.UserId, Convert.ToDateTime(BeginDate), Convert.ToDateTime(EndDate), Convert.ToBoolean(IsAllDay), Convert.ToInt32(EventId));

this.CalendarPanel1.EventStore.Reload();
this.CalendarPanel1.EventStore.DataBind();
EventEditWindow1.Hide();
}

protected void EventDelete(object sender, DirectEventArgs e)
{

Dictionary<string, object> EventToDelete = JSON.Deserialize<Dictionary<string, object>>(e.ExtraParams["Event"]);
object CalendarId = null;
EventEditWindow1.Hide();
EventToDelete.TryGetValue("EventId", out CalendarId);

SigmaSportCalendar.CalendarDelete(Convert.ToInt32( CalendarId));

this.CalendarPanel1.EventStore.DataBind();

}

protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{
//
}
}

[DirectMethod(Namespace = "CompanyX")]
public void ShowMsg(string msg)
{
X.Msg.Notify("Message", msg).Show();
}
}


Thank you for your help.

Daniil
Aug 08, 2012, 4:52 PM
Hi,

Please try to remove

this.CalendarPanel1.EventStore.Reload();

Does it help?

bossun
Aug 08, 2012, 9:56 PM
Hi,

Please try to remove

this.CalendarPanel1.EventStore.Reload();

Does it help?

No success, I already have tryed many combinations with databind(), refresh(), etc.. but doesn't work

Daniil
Aug 09, 2012, 5:13 AM
I think I have reproduced the problem. Investigating.

Thanks for the report.

bossun
Aug 09, 2012, 8:48 AM
By the way, can you check the other issue?

When adding a new event, the "IsNew" property is allays "False"

Thanks,

Daniil
Aug 09, 2012, 2:36 PM
I think I have reproduced the problem. Investigating.

The EventStore without any server proxy is not reloaded if there are already any events. It's made to improve performance and to do not loose changes.

According your scenario you should remove all events before binding new ones:

Example

this.CalendarPanel1.EventStore.RemoveAll();
this.CalendarPanel1.EventStore.DataBind();

Daniil
Aug 09, 2012, 2:54 PM
By the way, can you check the other issue?

When adding a new event, the "IsNew" property is allays "False"

Please set up it explicitly within a client side EventAdd listener:

rec.data[Ext.calendar.data.EventMappings.IsNew.name] = true;

bossun
Aug 09, 2012, 3:30 PM
THank you very much for you help and your efficiency.