Attributes not showing up after rebind using webservice

4 posts, 0 answers
  1. Ramin
    Ramin avatar
    9 posts
    Member since:
    Mar 2012

    Posted 30 Oct 2012 Link to this post

    So I have a custom attribute "typeFilter" on my scheduler object.  I have a tabpanel and when a different tab is selected, the customattribute in the scheduler changes and then I call rebind().  However, in my webservice getAppointments() function, the scheduler.attributes list is always 0.  Do I have to do something else to make sure the call to the webservice has the attributes filled in?

    Thank you
    Loren
  2. Boyan Dimitrov
    Admin
    Boyan Dimitrov avatar
    2035 posts

    Posted 31 Oct 2012 Link to this post

    Hello Loren,

    A SchedulerProvider class modification would be required in order to implement such functionality. Please use the provided code below as a sample approach:

    public override IEnumerable<Appointment> GetAppointments(ISchedulerInfo shedulerInfo)
        {
            ......
     
            List<Appointment> appointments = new List<Appointment>();
     
            using (DbConnection conn = OpenConnection())
            {
                DbCommand cmd = DbFactory.CreateCommand();
                cmd.Connection = conn;
                cmd.CommandText = "SELECT [ClassID], [Subject], [Start], [End], [RecurrenceRule], [RecurrenceParentId], [Reminder], [typeFilter] FROM [DbProvider_Classes]";
           using (DbDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        ......
                        Appointment apt = new Appointment();
                        apt.Attributes.Add("typeFilter", reader["typeFilter"].ToString());
                        ......
                    }
                }
         }
     }

    A easy and convenient way to retrieve an attribute value on the client-side would be:

    function OnClientAppointmentDataBound(sender, args) {
                var appointmentAttribute = args.get_appointment().get_attributes().getAttribute("typeFilter");
                 
            }

    You can find GetAppointments method in MyDbSchedulerProvider.cs file located in App_Data folder.
    Please find this sample project attached to this response.

    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.
  3. Ramin
    Ramin avatar
    9 posts
    Member since:
    Mar 2012

    Posted 31 Oct 2012 Link to this post

    Hi Boyan,

    Thank you for your response.  I dont think I was clear on my problem.

    In my client side code, I am modifying an attribute in the scheduler object and rebinding like so:
    var schedAttrs = scheduler.get_attributes();
    schedAttrs.removeAttribute("typeFilter");
    schedAttrs.setAttribute("typeFilter", typeFilter);
    scheduler.rebind();

    And then in my listprovider, i check for the filter id to only return the correct items:
    public override System.Collections.Generic.IEnumerable<Appointment> GetAppointments(RadScheduler owner)
            {
                var appointmentsList = new List<Appointment>();
                var filterType = owner.Attributes["typeFilter"];
    .
    .
    .
    .
    In fact, owner.Attributes is 0, oddly even though when I created the RadScheduler i added the attribute and could see it in the javascript.

    hopefully this is clearer of what my issue is.
  4. Boyan Dimitrov
    Admin
    Boyan Dimitrov avatar
    2035 posts

    Posted 05 Nov 2012 Link to this post

    Hello Loren,


    I am afraid that setting any attributes to the RadScheduler client-side object will not persist and will not be accessible in the WebService implementation. That is why we recommend you to use the approach of setting custom attributes to an appointment basis as shown in my previous response. 

    Do not hesitate to contact us if you have any further questions.

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