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

TagCloud forgets dataItem

5 Answers 49 Views
TagCloud
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 26 Jan 2011, 06:30 PM
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?

5 Answers, 1 is accepted

Sort by
0
Pero
Telerik team
answered on 28 Jan 2011, 06:44 PM
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.
0
Paul
Top achievements
Rank 1
answered on 02 Feb 2011, 12:41 PM
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?
0
Pero
Telerik team
answered on 04 Feb 2011, 05:48 PM
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.
0
Andrea
Top achievements
Rank 2
Iron
answered on 15 Feb 2011, 05:00 PM
Any news about Value? It's incredible that you have made a control without Value property.....
0
Accepted
Pero
Telerik team
answered on 16 Feb 2011, 08:58 AM
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.
Tags
TagCloud
Asked by
Paul
Top achievements
Rank 1
Answers by
Pero
Telerik team
Paul
Top achievements
Rank 1
Andrea
Top achievements
Rank 2
Iron
Share this question
or