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

[Solved] Radgrid and javascript question

4 Answers 152 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Corey
Top achievements
Rank 1
Corey asked on 04 Sep 2009, 08:28 PM
Hello everyone,

Here is my situation.

1.  Using a RadGrid.
2.  Using a EditForm template.
3.  In the edit form template i have a RadCalendar and a Listbox.
4.  In the list box i have a series of dates that i want to use to select dates in the RadCalendar.
5.  I want to use the RadCalendar to select dates.. and have it put into the listbox.
6.  I can see the RadCalendar in Javascript.. i can add/remove elements etc but I am having a hell of a time getting the javascript to see the listbox (so that i can update it).

Here is the code so far (work in progress)

 

function getElements(calendarInstance, args) {

 

 

1 var grid = $get('<%= grdElectives.ClientID %>');

 

2 alert(

'gridElectives found: ' + grid);

 

 

3 var dates = calendarInstance.get_selectedDates();

 

 

4 var i = 0;

 

 

5 for (i = 0; i < dates.length; i++) {

 

6 alert(dates[i]);

7 }

 

8 var todaysDate = new Date();

 

 

9 var todayTriplet = [todaysDate.getFullYear(), todaysDate.getMonth() + 1, todaysDate.getDate()];

 

 

10 var tomorrowTriplet = [todaysDate.getFullYear(), todaysDate.getMonth() + 1, todaysDate.getDate() + 1];

 

 

11 var selectedDates = [todayTriplet, tomorrowTriplet];

 

12 calendarInstance.selectDates(selectedDates,

true);

 

}

Line 1 gets the grid instance correctly (as line 2 is showing Grid Electives found: OBJECT in the alert box)
But i need to find the listbox control that is within that grid (the name of the listbox is lstDates)
I know that once i have an instance of the listbox i can read/write to it.... which is what i need to do despirately

Cannot for the life of me get this to work.

Any help is appreciated.

4 Answers, 1 is accepted

Sort by
0
Mira
Telerik team
answered on 09 Sep 2009, 11:52 AM
Hi Corey,

I recommend that you use the following code to find the ListBox:
 var listbox = $telerik.findElement($get("grdElectives"), "lstDates"); 

Sincerely yours,
Mira
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Corey
Top achievements
Rank 1
answered on 09 Sep 2009, 01:36 PM
Unfortunately that did not work.

I get a Microsoft JScript error

Microsoft JScript runtime error: 'null' is null or not an object

More information...

1.  The Calendar is inside of a HTML Table
2.  I am trying to capture the OnDateSelected client event... so that i can move the date selected over to the listbox control.
0
Mira
Telerik team
answered on 10 Sep 2009, 03:35 PM
Hi Corey,

I am attaching a sample project following your scenario - RadGrid with edit form template in which there are RadCalendar and RadListBox and when a date is selected from the calendar its value is added in he listbox.

Please take a look at it.

Kind regards,
Mira
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Jacob Button
Top achievements
Rank 1
answered on 10 Sep 2009, 06:04 PM
Corey,

Mira is correct, however if your radgrid is inside other controls you'll need to get the client id of it.  try something like this
var listbox = $telerik.findControl($get("<%= grdElectives.ClientID %>"), "lstDates"); 
Tags
Grid
Asked by
Corey
Top achievements
Rank 1
Answers by
Mira
Telerik team
Corey
Top achievements
Rank 1
Jacob Button
Top achievements
Rank 1
Share this question
or