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

Missing attributes on resources

7 Answers 96 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Mark Rabjohn
Top achievements
Rank 1
Mark Rabjohn asked on 29 May 2010, 01:30 PM
Hi,

I'm trying to get use attributes to pass some urls and icons around, so that I can incorporate a status icon next to the resource heading.

I've managed to come up with jQuery suitable for inserting the appropriate image element into the DOM, but when I look in my attributes, there aren't any. They were there on the server side however as it returned from GetResouces, so they don't appear to have been mapped to the client collection.

The code that I'm running on the client in response to a OnClientDataBound event is as follows:

        function refreshStatusIcons(sender, eventArgs) { 
            var allresources = sender.get_resources(); 
            var jobresources = allresources.getResourcesByType('Job'); 
 
            var resourceheaders = $('table.rsVerticalHeaderTable div.rsMainHeader', sender._element); 
 
            resourceheaders.each(function() { 
                var headerelement = $(this); 
 
                var icon = $('.ocStatusIcon', headerelement); 
                if (icon.size()==0) { 
                    headerelement.html('<img class="ocStatusIcon" />' + headerelement.html()); 
                    icon = $('.ocStatusIcon', headerelement); 
                } 
                var jobresource = jobresources.getResourceByTypeAndKey('Job''Res'+headerelement.text().trim()); 
                icon.attr('src', jobresource.getAttribute('IconURL')); 
            }); 
        } 
 

Clearly this is susceptible to changes in css class names and markup etc. so it's not perfect.

What do I have to do to get the resource's attributes to load into the client? Is this fixed in a later version? How do I download the latest version?

Cheers.


7 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 02 Jun 2010, 01:41 PM
Hi Mark,

Indeed, there was a problem with getting resource attributes on the client, but this should have been fixed. I suggest you try this scenario with the current version - 2010.1.519, which you can download from your Telerik account (see attached screencapture for reference).  Please, let me know how it goes.


All the best,
Peter
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Mark Rabjohn
Top achievements
Rank 1
answered on 03 Jun 2010, 01:04 PM
Hi Peter,

Thanks, I'll download the new version and see what happens.

I'm curious as to what the best way of altering content on the client is.

Is there a standard way to get a reference to a Resource header client side object and if so, is there a way of getting a reference to the DOM object that contains it's visual portion?

Similarly can this be done with Appointments and time headings etc?

I'm fine with jQuery if this can't be done, but as I said, it's not hugely future proof if you guys decide to change how the grid is rendered in the future.

Best Regards,

Mark
0
Mark Rabjohn
Top achievements
Rank 1
answered on 03 Jun 2010, 03:34 PM
Hi Peter,

I downloaded the Asp.Net Ajax Controls 2010.1.519.35, but this still doesn't work.

To reiterate:

1) I bind my scheduler to a webservice and the GetResources method returns the correct data.

Popping open the Resource collection on the server side, I can clearly see that the Attributes collection contains 2 items, of type System.Collections.Generic.KeyValuePair(Of String, String), and they contain the correct values.

2) On the client in response to OnClientDataBound:
    2a) allresources = sender.get_resources(); returns my resources as expected.
    2b) jobresources = allresources.getResourcesByType('Job'); returns all my job resources as expected.
    2c) jobresource = jobresources.getResourceByTypeAndKey('Job', 'Res'+resid); returns the expected resource.
    2d) jobresource.get_attributes().getAttribute('IconURL'); returns undefined;

I note also that jobresource._attributes is empty too, which is quite telling!

I presume that this is still a bug, or am I missing something obvious?

Best Regards,

Mark


0
Accepted
T. Tsonev
Telerik team
answered on 09 Jun 2010, 01:14 PM
Hello Mark,

Thank you for the detailed explanation of the problem.

I was able to reproduce this problem when using the 3.5 version of the Telerik.Web.UI assembly and an ASMX (ASP.NET 2.0) Web Service.

The problem turns out to be that the ASMX service is serializing the response using JavaScriptSerializer and the 3.5 version is deserializing it using DataContractJsonSerializer. There are few differences between the two (look at the table at the bottom of this article) that prevent the attributes dictionary from being deserialized.

The original reason for using DataContractJsonSerializer is that the JavaScriptSerializer was deprecated in .NET 3.5. It was then undeprecated in 3.5 SP1, but we've started building against SP1 only recently and haven't revisited this issue just yet.

My recommendation is to use a WCF service for 3.5 sites and ASMX service for 2.0 sites. This is a reliable solution for the moment and we'll try to improve the ASMX-in-3.5 support in the future.

Greetings,
Tsvetomir Tsonev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Mark Rabjohn
Top achievements
Rank 1
answered on 17 Jun 2010, 04:38 PM
Hi Tsvetomir,

A bit of a delay, but I've finally swapped by old web services for WCF ones, and it works a treat!

Cheers,

Mark
0
Robbie Hughes
Top achievements
Rank 1
answered on 12 Apr 2013, 09:15 AM
Hi Tsvetomir,

Have you solved this issue already? Because I'm using Telerik.Web.UI version 3.5 and I m still having this problem with resource's attributes coming empty from my asmx webservices.

Best Regards
0
Plamen
Telerik team
answered on 16 Apr 2013, 11:26 AM
Hi Robbie,

 
If you want to get the resources attributes in the OnClientAppointmentsPopulated event you have to  set ResourcePopulationMode="ClientSide" property o RadScheduler as for example in the code below and in the attached sample project:

function OnClientAppointmentsPopulated(sender, args) {
            alert(sender.get_resources().getResourcesByType("Teacher").getResource(0).get_attributes().getAttribute("Phone"));
        }

Hope this will be helpful.

Greetings,
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.
Tags
Scheduler
Asked by
Mark Rabjohn
Top achievements
Rank 1
Answers by
Peter
Telerik team
Mark Rabjohn
Top achievements
Rank 1
T. Tsonev
Telerik team
Robbie Hughes
Top achievements
Rank 1
Plamen
Telerik team
Share this question
or