I've been able to add a custom attribute to the advance form and works fine. However, instead of a textbox I would like to be able to show a checkbox to hold the boolean value. How can I go about making this custom attribute a checkbox?
Thanks
Thanks
13 Answers, 1 is accepted
0
Hello Nick,
You should set the checked state of the checkbox in the FormCreated event handler like this:
CustomAttribute should be set to "true" or "false" in order to be converted to boolean.
Kind regards,
Yana
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.
You should set the checked state of the checkbox in the FormCreated event handler like this:
protected void RadScheduler1_FormCreated(object sender, SchedulerFormCreatedEventArgs e) |
{ |
if (e.Container.Mode == SchedulerFormMode.AdvancedEdit) |
{ |
CheckBox ch = (CheckBox)e.Container.FindControl("CheckBox1"); |
ch.Checked = System.Convert.ToBoolean(e.Appointment.Attributes["CustomAttribute"]); |
} |
} |
CustomAttribute should be set to "true" or "false" in order to be converted to boolean.
Kind regards,
Yana
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.
0
Nick
Top achievements
Rank 1
answered on 07 May 2009, 01:33 AM
Thank you for the response. I tried adding this to my code and I'm now getting a 'Object reference not set to an instance of an object', 'NullReferenceExceptoin'. My custom attribute is called 'IsPublic'. It shows a value of True in the Custom Attribute text box that was generated.
I recieve the error on the second line of this code:
CheckBox ch = (CheckBox)e.Container.FindControl("CheckBox1");
ch.Checked = System.Convert.ToBoolean(e.Appointment.Attributes["IsPublic"]);
This code for the Custom Attribute works, it just that I need it as a check box and not a text box:
TextBox attrIsPublicTextBox = (TextBox)e.Container.FindControl("AttrIsPublic");
Thanks for the help.
I recieve the error on the second line of this code:
CheckBox ch = (CheckBox)e.Container.FindControl("CheckBox1");
ch.Checked = System.Convert.ToBoolean(e.Appointment.Attributes["IsPublic"]);
This code for the Custom Attribute works, it just that I need it as a check box and not a text box:
TextBox attrIsPublicTextBox = (TextBox)e.Container.FindControl("AttrIsPublic");
Thanks for the help.
0
Hi Nick,
I'm sorry for not explaining clear enough.
A checkbox with the same ID should be placed in a form template, for example AdvancedEditTemplate:
so you'll be able to find the checkbox in the FormCreated event handler and set its checked state as I showed you in my previous post.
Sincerely yours,
Yana
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.
I'm sorry for not explaining clear enough.
A checkbox with the same ID should be placed in a form template, for example AdvancedEditTemplate:
<AdvancedEditTemplate> |
<asp:CheckBox ID="CheckBox1" runat="server" /> |
</AdvancedEditTemplate> |
so you'll be able to find the checkbox in the FormCreated event handler and set its checked state as I showed you in my previous post.
Sincerely yours,
Yana
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.
0
Deepa Balasundaram
Top achievements
Rank 1
answered on 29 Oct 2009, 04:17 PM
Hello,
Even I want to implement the same functionality as explained by Nick. I am not getting any error messages. But the advanced edit form is not displayed.
Please suggest me some solutions.
Thanks,
Deepa
Even I want to implement the same functionality as explained by Nick. I am not getting any error messages. But the advanced edit form is not displayed.
Please suggest me some solutions.
Thanks,
Deepa
0
Hello Deepa,
Can you send us the code of your implementation so we can test it?
Kind regards,
Peter
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.
Can you send us the code of your implementation so we can test it?
Kind regards,
Peter
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
Deepa Balasundaram
Top achievements
Rank 1
answered on 03 Nov 2009, 05:26 PM
Hello Peter,
I have a field called "IsPrivate" to be associated with each appointment and I want this field to appear as a checkbox in the appointment edit form.
IsPrivate is one of the fields in my "events" table in the database. Each event has this field. When I use ResourceType, it pulls values of IsPrivate for all the events in the "events" table. I want the value of the "IsPrivate" to appear only once and it should be the IsPrivate value associated with that particular event.
I would like to implement "IsPrivate" in a way that we implement CustomArrtibutes using "CustomAttributeNames". I dont't know how to use "BooleanAttributeControl". I followed the instructions in the following link http://www.telerik.com/help/aspnet-ajax/schedule_advancedformtemplate.html But still I couldn't implement BooleanAttributeControls. Could you please send me "AdvancedFormTemplate" files which I can use to replace the existing "AdvancedFormTemplates" and implement BooleanAttributes?
Thank you,
Deepa
I have a field called "IsPrivate" to be associated with each appointment and I want this field to appear as a checkbox in the appointment edit form.
IsPrivate is one of the fields in my "events" table in the database. Each event has this field. When I use ResourceType, it pulls values of IsPrivate for all the events in the "events" table. I want the value of the "IsPrivate" to appear only once and it should be the IsPrivate value associated with that particular event.
I would like to implement "IsPrivate" in a way that we implement CustomArrtibutes using "CustomAttributeNames". I dont't know how to use "BooleanAttributeControl". I followed the instructions in the following link http://www.telerik.com/help/aspnet-ajax/schedule_advancedformtemplate.html But still I couldn't implement BooleanAttributeControls. Could you please send me "AdvancedFormTemplate" files which I can use to replace the existing "AdvancedFormTemplates" and implement BooleanAttributes?
Thank you,
Deepa
0
Hi Deepa,
Attached is a demo. Let us know if you have questions.
All the best,
Peter
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.
Attached is a demo. Let us know if you have questions.
All the best,
Peter
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
Deepa Balasundaram
Top achievements
Rank 1
answered on 09 Nov 2009, 05:21 PM
Hello Peter,
Thank you very much. It works fine. But when I check on "AllDayEvet" or "Recurrence" checkbox the corresponding panels are not displayed.
Please suggest me some solution.
Thanks,
Deepa
Thank you very much. It works fine. But when I check on "AllDayEvet" or "Recurrence" checkbox the corresponding panels are not displayed.
Please suggest me some solution.
Thanks,
Deepa
0
Hi Deepa,
We've managed to track down the issue down to the advanced form initialization code in the example. The template object is not recreated after an AJAX update. Here's the fixed code (changes in bold):
All the best,
Peter
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.
We've managed to track down the issue down to the advanced form initialization code in the example. The template object is not recreated after an AJAX update. Here's the fixed code (changes in bold):
// Dictionary containing the advanced template client object
// for a given RadScheduler instance (the control ID is used as key).
var
schedulerTemplates = {};
function
schedulerFormCreated(scheduler, eventArgs) {
// Create a client-side object only for the advanced templates
var
mode = eventArgs.get_mode();
if
(mode == Telerik.Web.UI.SchedulerFormMode.AdvancedInsert ||
mode == Telerik.Web.UI.SchedulerFormMode.AdvancedEdit) {
// Initialize the client-side object for the advanced form
var
formElement = eventArgs.get_formElement();
var
templateKey = scheduler.get_id() +
"_"
+ mode;
var
advancedTemplate = schedulerTemplates[templateKey];
if
(!advancedTemplate)
{
// Initialize the template for this RadScheduler instance
// and cache it in the schedulerTemplates dictionary
var
schedulerElement = scheduler.get_element();
var
isModal = scheduler.get_advancedFormSettings().modal;
advancedTemplate =
new
window.SchedulerAdvancedTemplate(schedulerElement, formElement, isModal);
advancedTemplate.initialize();
schedulerTemplates[templateKey] = advancedTemplate;
// Remove the template object from the dictionary on dispose.
scheduler.add_disposing(
function
() {
schedulerTemplates[templateKey] =
null
;
});
}
// Are we using Web Service data binding?
if
(!scheduler.get_webServiceSettings().get_isEmpty()) {
// Populate the form with the appointment data
var
apt = eventArgs.get_appointment();
var
isInsert = mode == Telerik.Web.UI.SchedulerFormMode.AdvancedInsert;
var
editSeries = eventArgs.get_editingRecurringSeries();
advancedTemplate.populate(apt, isInsert, editSeries);
}
}
}
All the best,
Peter
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
Jill-Connie Lorentsen
Top achievements
Rank 1
answered on 17 Apr 2013, 09:33 AM
An old thread, and not the same problem, but as I have reproduced my problem in the demo attached by Peter I chose to continue on this thread in stead of starting a new one.
I would like to set the (in this case) IsPrivate attribute to True at start up when adding a new appointment, but I can't get it to work. Please enlighten me.
Regards, Jill-Connie Lorentsen
I would like to set the (in this case) IsPrivate attribute to True at start up when adding a new appointment, but I can't get it to work. Please enlighten me.
Regards, Jill-Connie Lorentsen
0
Hello Jill,
Hope this will be helpful.
All the best,
Plamen
the Telerik team
You ca set the initially set value of the Checkbox by changing the following code in the BooleanAttributeControl.ascx.cs file:
[Bindable(BindableSupport.Yes, BindingDirection.TwoWay)]
public
string
Value
{
get
{
return
AttributeValue.Checked.ToString();
}
set
{
if
(
string
.IsNullOrEmpty(value))
{
AttributeValue.Checked =
true
;
}
else
{
AttributeValue.Checked = Convert.ToBoolean(value);
}
}
}
Hope this will be helpful.
All the best,
Plamen
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
Jill-Connie Lorentsen
Top achievements
Rank 1
answered on 25 Apr 2013, 08:30 AM
I have tried that, but I have two BooleanAttributeControls, and I want one to be default false and the other to be default true. In this case both are default true.
By setting break points it seems like the code is hit twice for each control, first with Value=True/False and then with Value="".
So, if I modify the code like shown below I get the desired behaviour, but is it the right way to do it?
Another thing, - having set break points I notice that they are hit when clicking Cancel on the advanced form. Is that correct?
Regards, Jill-Connie Lorentsen
By setting break points it seems like the code is hit twice for each control, first with Value=True/False and then with Value="".
So, if I modify the code like shown below I get the desired behaviour, but is it the right way to do it?
[Bindable(BindableSupport.Yes, BindingDirection.TwoWay)]
public string Value
{
get
{
return AttributeValue.Checked.ToString();
}
set
{
if (!string.IsNullOrEmpty(value))
{
AttributeValue.Checked = Convert.ToBoolean(value);
}
}
}
Another thing, - having set break points I notice that they are hit when clicking Cancel on the advanced form. Is that correct?
Regards, Jill-Connie Lorentsen
0
Hi Jill,
Plamen
the Telerik team
In case you have two checkboxes and they have to have different default value you will have to instantiate different user controls.
As for the other issue you mentioned -this is the default behavior of the advanced template form in RadScheduler.
hope this will information will be helpful.
Plamen
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.