Missing attributes on resources

8 posts, 1 answers
  1. Mark Rabjohn
    Mark Rabjohn avatar
    23 posts
    Member since:
    Jan 2010

    Posted 29 May 2010 Link to this post

    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.


  2. Peter
    Admin
    Peter avatar
    6637 posts

    Posted 02 Jun 2010 Link to this post

    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.
  3. Mark Rabjohn
    Mark Rabjohn avatar
    23 posts
    Member since:
    Jan 2010

    Posted 03 Jun 2010 Link to this post

    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
  4. Mark Rabjohn
    Mark Rabjohn avatar
    23 posts
    Member since:
    Jan 2010

    Posted 03 Jun 2010 Link to this post

    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


  5. Answer
    T. Tsonev
    Admin
    T. Tsonev avatar
    2834 posts

    Posted 09 Jun 2010 Link to this post

    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.
  6. Mark Rabjohn
    Mark Rabjohn avatar
    23 posts
    Member since:
    Jan 2010

    Posted 17 Jun 2010 Link to this post

    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
  7. Robbie Hughes
    Robbie Hughes avatar
    29 posts
    Member since:
    Jul 2009

    Posted 12 Apr 2013 Link to this post

    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
  8. Plamen
    Admin
    Plamen avatar
    3079 posts

    Posted 16 Apr 2013 Link to this post

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