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

Rebinding programatically added custom resource selected values on edit

5 Answers 31 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Bex
Top achievements
Rank 1
Bex asked on 17 Apr 2012, 11:07 AM
Hi

I know this must be quite simple, but none of the examples are quite doing what I am so I am unsure what I need to do!
I am setting custom resources to an appointment which are showing fine and can be selected when inserting, but when I am editing an appointment I don't know how to bind the selected values for the custom resource.

I have looked at this page http://www.telerik.com/community/code-library/aspnet-ajax/scheduler/customize-the-advanced-form-with-the-advanced-template-user-controls.aspx  which was suggested on a previous post but this appears to be just for custom advanced forms but I am not using  a custom form, I am just using custom resources.

A simplified version of how I am adding the custom resources:

if (!IsPostBack)
            {
                 SchToday.CustomAttributeNames = new string[] { "Added Users", "Type" };
                //type is added separately and works fine, the users are added separately as they are only added under certain circumstances.
               SetUsersResource();
}
  private void SetUsersResource()
        {
            UserDetailCollection allUSers = UserManager.GetAllUsers();
            ResourceType users = new ResourceType("Added Users");
 
            users.AllowMultipleValues = true;
            users.ForeignKeyField = "AppointmentId";
            SchToday.ResourceTypes.Add(users);
 
            foreach (UserDetail user in allUSers)
            {
                SchToday.Resources.Add(new Resource("Added Users", user.UserId, user.FullName));
            }
        }

When I bind the scheduler I an doing this:

SchToday.DataSource = GetSchedule();
Where GetSchedule returns a collection of appointments from a table set up as per the documentation.

The selected users are stored in a table called UserAppointments, where the appoinmentId is stored against the user ID.
How do I bind these values back so they are selected when I edit the appointment?

Bex



5 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 17 Apr 2012, 02:49 PM
Hello Becky,

It looks like you need to use custom attributes, so please take a look at this demo.

Regards,
Peter
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
Bex
Top achievements
Rank 1
answered on 17 Apr 2012, 02:57 PM
Hi Pete

Thanks for your reply!

Am I correct in thinking that attributes are single text are single text string values?
The custom resource I am adding produces a checkbox list where the user can multiple select.
How would this work with attributes and no custom advanced form?

Becky
0
Peter
Telerik team
answered on 17 Apr 2012, 03:16 PM
Hello,

Yes, your assumption is correct - 'attributes are single text are single text string values'. If you need a checkbox list and multi-value resources, the only way to implement this is to create a special type of provider.

Greetings,
Peter
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
Bex
Top achievements
Rank 1
answered on 17 Apr 2012, 03:20 PM
I made a bit of a typo there! :)
Is there no way of just binding them? Even on the appointment created?
Really don't want to re-do the whole thing!
0
Peter
Telerik team
answered on 19 Apr 2012, 03:40 PM
Hi Bex,

You need to define resources as shown in this demo.

Regards,
Peter
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
Bex
Top achievements
Rank 1
Answers by
Peter
Telerik team
Bex
Top achievements
Rank 1
Share this question
or