TagCloud forgets dataItem

6 posts, 1 answers
  1. Paul
    Paul avatar
    55 posts
    Member since:
    Nov 2010

    Posted 26 Jan 2011 Link to this post

    Hi. I'm trying to use the RadTagCloud. I am trying to build the content iteratively with code behind (upon certain events items will get added to the cloud).

    In code behind I have:
                    var nodes = from n in dContext.table where select n;
                    foreach (var j in nodes)
                    {
                        RadTagCloudItem item = new RadTagCloudItem()
                        {
                            Text = j.Description,
                            DataItem = j.CtId
                        };
                        myCloud.Items.Add(item);
                    }

    This works fine. If I watch the cloud in debug mode I items.count increases and I can view individual RadTagCloudItems and they contain text and dataItems.

    However, I also have a method for the itemClick event:
        protected void myCloud_ItemClick(object sender, RadTagCloudEventArgs e)
        {
            doSomething(Convert.ToInt16( e.Item.DataItem));
        }

    When this executes the e.item.DataItem is null and if I view myCloud the dataitem for every item in the items collection is null. WHY?
  2. Pero
    Admin
    Pero avatar
    1156 posts

    Posted 28 Jan 2011 Link to this post

    Hi Paul,

    The DataItem property provides a reference to the data object from the DataSource, to which the respective TagCloud item was bound. It does not store the actual data in the ViewState, and that's why it is lost between postbacks. If you want to access the current DataItem, you should bind the TagCloud on every trip to the server, or bind it declaratively in the aspx.

    We are planning on introducing an additional Value property for the next release that will come handy in situations where the user wants to associate more information with the respective TagCloud item.

    Kind regards,
    Pero
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Paul
    Paul avatar
    55 posts
    Member since:
    Nov 2010

    Posted 02 Feb 2011 Link to this post

    Thanks for the reply. This is causing me a few problems deciding how to implement the site that I am developing. Maybe I just don't yet understand the full capabilities and there is a way that I can do what I want.

    I don't have a simple datasource that I can provide for the tag cloud. I want to use the cloud to present some options to the user and from a code perspective each option has a text and a numeric element. The numeric element is actually an Id for the database record. However, there is no way to generate the cloud contents from a simple datasource and they are generated by code behind. However, that code involves some complex queries that I don't want to repeatedly perform - ie I just want to generate the TagCloud's contents once. One (not very good) option is that I assign the numeric value to the TagCloudItem's weight property and then design the cloud so that there is no variation in text size/colour. The weight is persisted so that sort of solves my problem but isn't very good.

    Is there any way, at present, to only create the dataitems once and have them persist? When you say that I need to bind them on every trip to the server do you mean recreate the cloud contents from scratch? Are there any timescales for the value property?
  5. Pero
    Admin
    Pero avatar
    1156 posts

    Posted 04 Feb 2011 Link to this post

    Hello Paul,

    For the time being, there is no way to preserve the DataItem objects only by binding the TagCloud once.
    The Value property of the TagCloud item will appear next week in the internal build, so I suppose it would be the best to wait a couple of days, and try the new build.
    The official release where this feature will appear is scheduled for the middle of March.

    Regards,
    Pero
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  6. Andrea
    Andrea avatar
    64 posts
    Member since:
    Jan 2005

    Posted 15 Feb 2011 Link to this post

    Any news about Value? It's incredible that you have made a control without Value property.....
  7. Answer
    Pero
    Admin
    Pero avatar
    1156 posts

    Posted 16 Feb 2011 Link to this post

    Hello Andrea,

    This property has been added to the RadTagCloudItem object, and you should download the latest internal build to use it. The property will be available in the next official release scheduled for the next month (mid-March 2011). It will also be available in the Beta, which should be out by the end of February.

    Kind regards,
    Pero
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017