This is a migrated thread and some comments may be shown as answers.

Dates from DomElements...

1 Answer 62 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Bob Pinna
Top achievements
Rank 1
Bob Pinna asked on 04 Aug 2009, 06:22 PM
I want to get the date range of a week from a client side RowHeaderClick event (so that I can send it in a web services call).

I can get the week number from the inner text of the dom element (see below).

I can see several ways to turn the week number into a date:

1. If I get the <td> cell that is the first "next sibling", is there a way to determine the date triplet (in which case I wouldn't even need the week number)?

2. Is there a way to get the first date triplet or the first week number being displayed in a multi-view calendar?

...
function OvernightCalendar_OnRowHeaderClick(calendarInstance, args)
{
  // don't select, we're just using the click to style the week

  args.set_cancel(true);

  // Get the dom element
  var e = args.get_domElement();

  // The inner text holds the week number
  var weekNumber = e.innerText;
  Sys.Debug.trace('Week Number: ' + weekNumber);
  
  // walk the td cells from the row, styling each cell
  var e = e.nextSibling;
  while (e != null) {
    styleCell(e);
    e = e.nextSibling;
  }
}

1 Answer, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 07 Aug 2009, 07:15 AM
Hi Bob,

The first date in a multimonth calendar view can be obtained by

function OvernightCalendar_OnRowHeaderClick(calendarInstance, args)
{
     var clickedViewID = args.get_domElement().parentNode.parentNode.parentNode.id;
     var dateTriplet = calendarInstance.get__ViewsHash()[clickedViewID][0];
}

dateTriplet is an array, in which the year is the first element, the month is second, the day is third.

Note that the month number (dateTriplet[1]) corresponds to the 'human" month number (e.g. 8 = August), while in Javascript dates August is equal to 7.

So, from the above triplet you can get the year and the month. You have to get the date from the table cell after the clicked row header, by using nextSibling.


Greetings,
Dimo
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Calendar
Asked by
Bob Pinna
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Share this question
or