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

Access controls in advanced insert form from the client side to set subject text

2 Answers 76 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
David Harman
Top achievements
Rank 1
David Harman asked on 07 Mar 2013, 11:20 PM
Hi,

I have a RadScheduler control which is bound to appointments client side via a web service. I have defaulted the control to open the advanced insert/edit form when inserting/updating appointments. I would like to be able to pre-set the text in the subject text box when inserting a new appointment. I have hooked up to the OnClientFormCreated event and tried access the controls from javascript and set the text. I have tried the following:

var subjectJQueryObj = $telerik.$("[id$='Subject']");
var subjectBox = document.getElementById(subjectJQueryObj.attr('id'));
subjectBox.value = "hello";
 and also:
var subjectJQueryObj = $telerik.$("[id$='Subject']");
var subjectRadTextBox = $find(subjectJQueryObj.attr("id"));
subjectRadTextBox.set_value("hello");

Occasionally when I place an alert after these pieces of code I can see the text in the text box but once the function completes it is removed and left with a blank text box.

Can this functionality be achieved? Any help much appreciated.

Thanks

David

2 Answers, 1 is accepted

Sort by
0
David Harman
Top achievements
Rank 1
answered on 08 Mar 2013, 02:48 PM
I think I have found the solution to my original question. By getting the appointment passed to the OnClientFormCreated event handler I can then update the subject message - this is then populated into the edit/insert form.

var appt = args.get_appointment();
appt.set_subject("subject text here");

I have an additional but related problem I am still struggling to solve. I have several resources associated with each appointment and I would like to set a few by default when an appointment is being inserted. I was hoping to use the appointment object as above to set resources for when a new appointment is being created however I can't find any information on how to create a resource object in javascript to be able to add to the appointment object.

Again any help would be much appreciated.

Regards

David
0
David Harman
Top achievements
Rank 1
answered on 08 Mar 2013, 03:37 PM
I have now found how to do this too. I pass all the resources to the RadScheduler control on the server side during the initial load. In the OnClientFormCreated event handler I can retrieve the resources. I can then loop through each resource until I find the one I wish to use and then add it to the resource collection for the appointment object.

var resources = sender.get_resources().getResourcesByType("ReourceType");
var chosenResource;
 
resources.forEach(function (res)
{
    if (res.get_text() == "ResourceText")
    {
        chosenResource = res;
    }
});
 
var appt = args.get_appointment();
appt.get_resources().add(chosenResource);

Hope the above will be of use to someone at sometime. I spent hours last night trying to sort this. A few hours break away from it and it all seems so clear now!!

Regards

David
Tags
Scheduler
Asked by
David Harman
Top achievements
Rank 1
Answers by
David Harman
Top achievements
Rank 1
Share this question
or