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

Attributes not showing up after rebind using webservice

3 Answers 54 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Ramin
Top achievements
Rank 1
Ramin asked on 30 Oct 2012, 05:29 PM
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

3 Answers, 1 is accepted

Sort by
0
Boyan Dimitrov
Telerik team
answered on 31 Oct 2012, 03:57 PM
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.
0
Ramin
Top achievements
Rank 1
answered on 31 Oct 2012, 06:30 PM
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.
0
Boyan Dimitrov
Telerik team
answered on 05 Nov 2012, 03:31 PM
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.
Tags
Scheduler
Asked by
Ramin
Top achievements
Rank 1
Answers by
Boyan Dimitrov
Telerik team
Ramin
Top achievements
Rank 1
Share this question
or