I have got one list with 5 sort of items:
Kontrakt | Pracownik | Dzien | ID | Procenty
And When i Have 1000 elements its render me very slow on calendar. About 5-6 secounds. How can I do it fdaster and analyse them. Can I put the indexer on column ?
I have got that code to render on Calendar:
protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
{
e.Cell.VerticalAlign = VerticalAlign.Top;
SPWeb witryna = SPContext.Current.Web;
SPListItemCollection listaDniPrzeznaczonychNaProjekt = witryna.Lists["Szczegoly"].Items;
// Gdy nie ma zaznaczonej osoby to wtedy wyświetlamy wszystkie daty urlopów
int index;
if (DropDownList1.SelectedItem.Text == "<-- Wszystcy pracownicy -->" || DropDownList1.SelectedItem.Text == "")
{
foreach (SPListItem olistaDniPrzeznaczonychNaProjekt in listaDniPrzeznaczonychNaProjekt)
{
if (e.Day.Date.Date.ToShortDateString() == Convert.ToDateTime(olistaDniPrzeznaczonychNaProjekt["Dzien"]).ToShortDateString())
{
e.Cell.Style.Add("background-color", "#FF0000");
e.Cell.CssClass = "dni_swiateczne";
}
}
}
else
// Renderowanie urlopu dla pojedyńczej zaznaczonej osobie
{
foreach (SPListItem olistaDniPrzeznaczonychNaProjekt in listaDniPrzeznaczonychNaProjekt)
{
index = olistaDniPrzeznaczonychNaProjekt["Pracownik"].ToString().IndexOf("#");
if (DropDownList1.SelectedItem.Text == olistaDniPrzeznaczonychNaProjekt["Pracownik"].ToString().Substring(index + 1))
{
if (e.Day.Date.Date.ToShortDateString() == Convert.ToDateTime(olistaDniPrzeznaczonychNaProjekt["Dzien"]).ToShortDateString())
{
e.Cell.Style.Add("background-color", "#F5BCA9");
e.Cell.CssClass = "dni_swiateczne";
e.Cell.Controls.Add(new LiteralControl(("<p style='color:blue; font-size:8px;'>" + olistaDniPrzeznaczonychNaProjekt["Kontrakt"].ToString() + "</p><p style='color:#5D198E;'>" + olistaDniPrzeznaczonychNaProjekt["Procenty"].ToString().Substring(3) + "</p>")));
}
}
}
}
SPWeb witryna1 = SPContext.Current.Web;
SPListItemCollection listaDniSwiatecznych = witryna1.Lists["DR2013 Święta"].Items;
foreach (SPListItem olistaDniSwiatecznych in listaDniSwiatecznych)
{
// Wyświetlenie na kalendarzu weekendów
if (e.Day.Date.Date.DayOfWeek.ToString() == "Saturday" || e.Day.Date.Date.DayOfWeek.ToString() == "Sunday")
{
e.Cell.Style.Add("background-color", "#FF9900");
e.Cell.CssClass = "dni_swiateczne";
}
// Wyświetlenie na kalendarzu dni świątecznych
if (e.Day.Date.Date.ToShortDateString() == Convert.ToDateTime(olistaDniSwiatecznych["Data"]).ToShortDateString())
{
e.Cell.Style.Add("background-color", "#FFFF00");
e.Cell.CssClass = "dni_swiateczne";
e.Cell.Controls.Add(new LiteralControl(("<p style='color:red; font-size:8px;'>" + olistaDniSwiatecznych["Data"].ToString().Substring(0, 10) + "</p>")));
}
}
} // Koniec protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)