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

How to select the same number of timeslots as the property NumberOfHoveredRows

3 Answers 66 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Kristian
Top achievements
Rank 2
Kristian asked on 09 Feb 2013, 10:17 PM
Hi,
I'm new on this forum and have just bought the Telerik ASP Ajax controls.
I have started using the Scheduler and have a problem.

I want the scheduler to selected the same rows that are hovered (using the property NumberOfHoveredRows).
So when the user clicks in the scheduler the rows are selected by automatic. As it is now only one row is selected.

Is this possible to do by javascript somehow?

I can only find the function get_selectedSlots() not set_selectedSlots().

Please help me as I need to have this to work!

Regards Kristian

3 Answers, 1 is accepted

Sort by
0
Boyan Dimitrov
Telerik team
answered on 13 Feb 2013, 03:55 PM
Hello,

An easy and convenient way of achieving such functionality would be to use the RadScheduler OnClientTimeSlotClick client-side event handler:
//markup code
<telerik:RadScheduler ID="RadScheduler1" runat="server" NumberOfHoveredRows="5" OnClientTimeSlotClick="ClientTimeSlotClick" SelectedView="Dayview"></telerik:RadScheduler>
//JavaScript
function ClientTimeSlotClick(sender, args) {
    var timeSlotRowIndex = args.get_targetSlot().get_rawIndex().rowIndex;
    var timeSlotCellIndex = args.get_targetSlot().get_rawIndex().cellIndex;
    var numberOfHoveredRows = sender.get_numberOfHoveredRows();
    for (var i = 1; i < numberOfHoveredRows; i++) {
        var currentSlotDom = $telerik.$(".rsContentTable").children().children()[timeSlotRowIndex + i].children[timeSlotCellIndex];
        var timeSlot = sender.get_activeModel().getTimeSlotFromDomElement(currentSlotDom);               
        timeSlot.set_selected(true);
    }
 
}

Please find more information about RadScheduler client-side programming here.

Kind regards,
Boyan Dimitrov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Kristian
Top achievements
Rank 2
answered on 13 Feb 2013, 07:26 PM
Thansk!! 
That worked perfect!

But, i have another problem. When I do this, the timeslots are selected, but the old one is still there when i click another timeslot.
I wan't the old ones selected to be cleared out as I click another timeslot.

Thanks!

Regards Kristian
0
Boyan Dimitrov
Telerik team
answered on 18 Feb 2013, 12:20 PM
Hello,

An easy and convenient way of achieving that functionality would be to modify your ClientTimeSlotClick client-side function as shown in the code snippet below:
//JavaScript
function ClientTimeSlotClick(sender, args) {
    $telerik.$(".rsContentTable td.rsSelectedSlot").removeClass('rsSelectedSlot');
    var timeSlotRowIndex = args.get_targetSlot().get_rawIndex().rowIndex;
    var timeSlotCellIndex = args.get_targetSlot().get_rawIndex().cellIndex;
    var numberOfHoveredRows = sender.get_numberOfHoveredRows();
    for (var i = 0; i < numberOfHoveredRows; i++) {
        var currentSlotDom = $telerik.$(".rsContentTable").children().children()[timeSlotRowIndex + i].children[timeSlotCellIndex];
        var timeSlot = sender.get_activeModel().getTimeSlotFromDomElement(currentSlotDom);
        timeSlot.set_selected(true);
    }
 
}

This will unselect all already selected time slots before you executing your custom code in your event handler.
Please keep in mind that in this case your iterate counter should start from "0" instead of "1" as shown in the second highlighted area.

Kind regards,
Boyan Dimitrov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Scheduler
Asked by
Kristian
Top achievements
Rank 2
Answers by
Boyan Dimitrov
Telerik team
Kristian
Top achievements
Rank 2
Share this question
or