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

How remove Rad Clod item From Client Side like facebook tags

3 Answers 58 Views
TagCloud
This is a migrated thread and some comments may be shown as answers.
Umut
Top achievements
Rank 1
Umut asked on 17 Sep 2010, 11:51 AM
Hello again,

How can I remove rad Cloud item from tag list by using javascript from Client Side.?

I couldn't see any function about this property in help document. 

I want to remove when user click on it. Maybe we can put remove images left side each tag.

can we put dynamic "remove image" ( maybe image button ) for every tag ?  Pls help.

 

function OnClientItemClicking(cloud, args) {

 

 

if (cloud.get_id() == "RadTagCloudCustomer")
 
{

 

 ??????? // remove this item from list.

}

 

 

args.set_cancel(

true);

 

}



3 Answers, 1 is accepted

Sort by
0
Umut
Top achievements
Rank 1
answered on 17 Sep 2010, 04:07 PM
can anyone help me ?
0
Cori
Top achievements
Rank 2
answered on 17 Sep 2010, 10:03 PM

Hello Umut,

You can handle the OnClientItemClicked event and add this piece of code to remove the selected item:

function OnClientItemClicked(sender, args) {
                $telerik.$(args.get_item().get_element()).remove();             
            }

I hope that helps.
0
Pero
Telerik team
answered on 22 Sep 2010, 09:22 AM
Hi Umut,

There is no built-in way that will remove a TagCloud item on the client-side. This can be done on the server only. For example, the following code removes the item by finding it in the Items collection using its Text. Please note that the Text must be unique.

.aspx
<telerik:RadScriptManager ID="RadScriptManager1" runat="server">
</telerik:RadScriptManager>
<div>
    <asp:Label ID="Label1" runat="server"></asp:Label>
</div>
<telerik:RadTagCloud ID="TagCloud1" runat="server" Width="400px">
    <Items>
        <telerik:RadTagCloudItem Text="ASP.NET" Weight="12" />
        <telerik:RadTagCloudItem Text="AJAX" Weight="134" />
        <telerik:RadTagCloudItem Text="VB" Weight="56" />
        <telerik:RadTagCloudItem Text="C#" Weight="38" />
        <telerik:RadTagCloudItem Text="Web" Weight="73" />
        <telerik:RadTagCloudItem Text="jQuery" Weight="23" />
        <telerik:RadTagCloudItem Text=".NET" Weight="78" />
        <telerik:RadTagCloudItem Text="Code" Weight="50" />
    </Items>
</telerik:RadTagCloud>
<asp:Button ID="Button1" runat="server" Text="Remove TagCloudItem Named 'AJAX'" OnClick="Button1_Click" />
<br />
<asp:Button ID="ButtonPostback" runat="server" Text="PostBack" />

.cs
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
 
using System.Data;
using System.Configuration;
using System.Web.Security;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Telerik.Web.UI;
 
public partial class Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        RadTagCloudItem itemToRemove = new RadTagCloudItem();
        itemToRemove = FindItemByText(TagCloud1, "AJAX");
        TagCloud1.Items.Remove(itemToRemove);
    }
 
    private RadTagCloudItem FindItemByText(RadTagCloud tagCloud, string itemText)
    {
        RadTagCloudItem itemToRemove = new RadTagCloudItem();
        foreach (RadTagCloudItem item in tagCloud.Items)
        {
            if (string.Compare(item.Text, itemText) == 0)
            {
                itemToRemove = item;
                return itemToRemove;
            }
        }
        return itemToRemove;
    }
}


Greetings,
Pero
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
Tags
TagCloud
Asked by
Umut
Top achievements
Rank 1
Answers by
Umut
Top achievements
Rank 1
Cori
Top achievements
Rank 2
Pero
Telerik team
Share this question
or