PDA

View Full Version : [CLOSED] How to get Calendar working with mvc



Pyropace
Jan 10, 2013, 10:38 PM
Hello,

I need an example on how to get calendar working with mvc

the following code


<ext:ResourceManager ID="ResourceManager1"
runat="server" />

<ext:Viewport ID="Viewport1" runat="server" Layout="Border">
<Items>
<ext:CalendarPanel
ID="CalendarPanel1"
runat="server"
Region="Center"
ActiveIndex="2"
Border="false">
<CalendarStore ID="CalendarStore1" runat="server">
<Calendars>
<ext:CalendarModel CalendarId="1" Title="Home" />
<ext:CalendarModel CalendarId="2" Title="Work" />
<ext:CalendarModel CalendarId="3" Title="School" />
<ext:CalendarModel CalendarId="4" Title="Other" />
</Calendars>
</CalendarStore>
<EventStore ID="evenStore1" NoMappings="True">
<Proxy>
<ext:AjaxProxy Url='<%# Url.Action("CalendarData") %>' Json="True">
<Reader>
<ext:JsonReader Root="result" />
</Reader>
</ext:AjaxProxy>
</Proxy>
<Mappings>
<ext:ModelField Name="StartDate" Type="Date" DateFormat="M$" />
<ext:ModelField Name="EndDate" Type="Date" DateFormat="M$" />
</Mappings>
<Listeners>
<BeforeSync Handler="Ext.Msg.alert('Sync', 'The EventStore initiates a sync request after that action. The EventStore synchronization is not implemented in that example.');
this.commitChanges();
return false;" />
</Listeners>
</EventStore>
<MonthView ID="MonthView1"
runat="server"
ShowHeader="true"
ShowWeekLinks="true"
ShowWeekNumbers="true" />
</ext:CalendarPanel>
</Items>
</ext:Viewport>

with this view

public ActionResult CalendarData()
{
var now = DateTime.Now.Date;
var query =
new
{
EventId = 500,
CalendarId = 1,
Title = "Sample",
StartDate = DateTime.Now.AddDays(-3),
EndDate = DateTime.Now,
IsAllDay = false,
Notes = "This is a sample"
};

return new AjaxResult() { Result = query };
}

is rending the calendar but it is not making a request to get calendar data, what i am i doing wrong ?

I also get this ( see attached image ) java script error

5413


Thanks

Baidaly
Jan 11, 2013, 2:34 AM
Hello!

You should set AutoDataBind attribute to true:



<ext:AjaxProxy Url='<%# Url.Action("CalendarData") %>' Json="True" AutoDataBind="True">
<Reader>
<ext:JsonReader Root="result" />
</Reader>
</ext:AjaxProxy>

Pyropace
Jan 11, 2013, 4:00 PM
Hello!

You should set AutoDataBind attribute to true:



<ext:AjaxProxy Url='<%# Url.Action("CalendarData") %>' Json="True" AutoDataBind="True">
<Reader>
<ext:JsonReader Root="result" />
</Reader>
</ext:AjaxProxy>



Thanks that worked, ok this AutoDataBind, has caused me a lot of problems, what is the general rule for it, when do you need to specify it ?

in some examples that i did before such as


Html.X().ComboBoxFor(m => m.CompanyId)
.TriggerAction(TriggerAction.All)
.AllowBlank(false)
.ID("comboBoxCompany")
.ValidateOnBlur(true)
.IndicatorIcon(Icon.Key)
.Width(500)
.ForceSelection(true)
.EmptyText("please choose a company")
.SelectOnFocus(true)
.DisplayField("name")
.ValueField("id")
.TypeAhead(true)
.ValueNotFoundText("... loading ...")
.Store(Html.X().Store().AutoLoad(false)
.Model(Html.X().Model().IDProperty("Id")
.Fields(
new ModelField("id", ModelFieldType.String) { Mapping = "Id" },
new ModelField("name", ModelFieldType.String) { Mapping = "Name" }
)
).Proxy(Html.X().AjaxProxy()
.Url(Url.Action("GetCompanies"))
.Reader(Html.X().JsonReader().Root("data")))
.Parameters(ps => ps.Add(new StoreParameter("result", "App.comboBoxCompany.getValue()", ParameterMode.Raw)))
.Listeners(ls => ls.Load.Handler = @" var combo = App.comboBoxCompany;
combo.setValue(records[0].get(combo.valueField));")),


but in situations like this calendar it is needed, so what would you say is a general rule to follow ?

Baidaly
Jan 11, 2013, 9:17 PM
Briefly, it should be used with ASPX markup and with special <%# %> syntax for DataBinding. If you've set AutoDataBind to true Ext.NET binds your values automatically.

You can read more information on this page http://support.microsoft.com/kb/307860/en-us .

Pyropace
Jan 11, 2013, 9:38 PM
Briefly, it should be used with ASPX markup and with special <%# %> syntax for DataBinding. If you've set AutoDataBind to true Ext.NET will bind your values automatically.

You can read more information on this page http://support.microsoft.com/kb/307860/en-us .


great thanks