Hello
I want know if i can or is possible show week numbers in the month view, specifically to the left corner cells.
Greetings
I want know if i can or is possible show week numbers in the month view, specifically to the left corner cells.
Greetings
6 Answers, 1 is accepted
0
Hi Ana,
Thank you for your question.
Yes, this can be achieved by inheriting from RadScheduler and changing the text of the left header cells as it is shown in the following code snippet:
You should also replace all your RadScheduler instances with MyScheduler ones in order to get this working.
I hope you find this useful. Feel free to ask if you have any further questions.
Greetings,
Ivan Todorov
the Telerik team
Thank you for your question.
Yes, this can be achieved by inheriting from RadScheduler and changing the text of the left header cells as it is shown in the following code snippet:
public
class
MyScheduler : RadScheduler
{
public
static
int
GetWeekNumber(DateTime dtPassed)
{
CultureInfo ciCurr = CultureInfo.CurrentCulture;
int
weekNum = ciCurr.Calendar.GetWeekOfYear(dtPassed, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday);
return
weekNum;
}
public
override
void
InvalidateElement(Telerik.WinControls.RadElement element)
{
if
(
this
.ActiveViewType == SchedulerViewType.Month)
{
foreach
(RadElement child
in
(
this
.SchedulerElement.ViewElement
as
SchedulerMonthViewElement).VerticalHeader.Children)
{
SchedulerHeaderCellElement cell = (child
as
SchedulerHeaderCellElement);
if
(cell !=
null
)
{
cell.Text = GetWeekNumber(cell.Date).ToString();
}
}
}
base
.InvalidateElement(element);
}
public
override
string
ThemeClassName
{
get
{
return
typeof
(RadScheduler).FullName;
}
set
{
base
.ThemeClassName = value;
}
}
}
You should also replace all your RadScheduler instances with MyScheduler ones in order to get this working.
I hope you find this useful. Feel free to ask if you have any further questions.
Greetings,
Ivan Todorov
the Telerik team
Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!
0
Ana
Top achievements
Rank 1
answered on 25 Jul 2011, 09:54 AM
Hi Ivan Todorov
I apply the code that you give me, but i found a error when i apply the code ( as shown in the image that will attached ).
Can you help me ?
Greetings
I apply the code that you give me, but i found a error when i apply the code ( as shown in the image that will attached ).
Can you help me ?
Greetings
0
Hello Ana,
The most probable reason for this error is the usage of a grouping by resource. In this case, you should use the following InvalidateElement function which covers both scenarios:
I hope this is useful. If you are still experiencing problems, you can open a support ticket and send us your project. This will help us investigate the complete scenario and provide you with more accurate answers.
Kind regards,
Ivan Todorov
the Telerik team
The most probable reason for this error is the usage of a grouping by resource. In this case, you should use the following InvalidateElement function which covers both scenarios:
public
override
void
InvalidateElement(Telerik.WinControls.RadElement element)
{
if
(
this
.ActiveViewType == SchedulerViewType.Month)
{
if
(
this
.GroupType == Telerik.WinControls.UI.GroupType.Resource)
{
foreach
(SchedulerMonthViewElement viewElement
in
(
this
.SchedulerElement.ViewElement
as
SchedulerMonthViewGroupedByResourceElement).GetMonthViewElements())
foreach
(RadElement child
in
viewElement.VerticalHeader.Children)
{
SchedulerHeaderCellElement cell = (child
as
SchedulerHeaderCellElement);
if
(cell !=
null
)
{
cell.Text = GetWeekNumber(cell.Date).ToString();
}
}
}
else
{
if
(
this
.ActiveViewType == SchedulerViewType.Month)
{
foreach
(RadElement child
in
(
this
.SchedulerElement.ViewElement
as
SchedulerMonthViewElement).VerticalHeader.Children)
{
SchedulerHeaderCellElement cell = (child
as
SchedulerHeaderCellElement);
if
(cell !=
null
)
{
cell.Text = GetWeekNumber(cell.Date).ToString();
}
}
}
}
}
base
.InvalidateElement(element);
}
I hope this is useful. If you are still experiencing problems, you can open a support ticket and send us your project. This will help us investigate the complete scenario and provide you with more accurate answers.
Kind regards,
Ivan Todorov
the Telerik team
Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!
0
Peter
Top achievements
Rank 1
answered on 16 May 2013, 03:49 PM
Hi,
the override of the method InvalidateElement(Telerik.WinControls.RadElement) is not possible because it is not present anymore. How can I achieve the same behaviour with todays releases?
Thank you in advance for your answer.
Best,
Peter
the override of the method InvalidateElement(Telerik.WinControls.RadElement) is not possible because it is not present anymore. How can I achieve the same behaviour with todays releases?
Thank you in advance for your answer.
Best,
Peter
0
Hi Peter,
Thank you for writing.
You can use the ElementInvalidated event to achieve the same result with the new version. Here is a code example:
I hope this will be useful. Should you have further questions, I would be glad to help.
Regards,
Ivan Petrov
the Telerik team
Thank you for writing.
You can use the ElementInvalidated event to achieve the same result with the new version. Here is a code example:
this
.radScheduler1.ElementInvalidated += radScheduler1_ElementInvalidated;
private
void
radScheduler1_ElementInvalidated(
object
sender, EventArgs e)
{
SchedulerHeaderCellElement cell = sender
as
SchedulerHeaderCellElement;
if
(cell !=
null
&& cell.Parent
is
MonthViewVerticalHeader)
{
cell.Text =
"Week# "
+ GetWeekNumber(cell.Date).ToString();
}
}
I hope this will be useful. Should you have further questions, I would be glad to help.
Regards,
Ivan Petrov
the Telerik team
RadChart for WinForms is obsolete. Now what?
0
Peter
Top achievements
Rank 1
answered on 13 Jun 2013, 02:45 PM
Hi Ivan,
this solved my Issue. Thank you very much.
Best,
Peter
this solved my Issue. Thank you very much.
Best,
Peter