Rebinding programatically added custom resource selected values on edit

6 posts, 0 answers
  1. Bex
    Bex avatar
    53 posts
    Member since:
    Jul 2011

    Posted 17 Apr 2012 Link to this post

    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



  2. Peter
    Admin
    Peter avatar
    6637 posts

    Posted 17 Apr 2012 Link to this post

    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.
  3. Bex
    Bex avatar
    53 posts
    Member since:
    Jul 2011

    Posted 17 Apr 2012 Link to this post

    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
  4. Peter
    Admin
    Peter avatar
    6637 posts

    Posted 17 Apr 2012 Link to this post

    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.
  5. Bex
    Bex avatar
    53 posts
    Member since:
    Jul 2011

    Posted 17 Apr 2012 Link to this post

    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!
  6. Peter
    Admin
    Peter avatar
    6637 posts

    Posted 19 Apr 2012 Link to this post

    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.
Back to Top