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

Change sorting text in radgrid

11 Answers 394 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Marta
Top achievements
Rank 1
Marta asked on 24 Jun 2009, 03:56 PM
hi,

I am trying to change the text "Click here to sort" which appears when I hover over the title of the GridHyperLinkColumns in my radgrid. I want to keep the hover text, but change it to whatever I like, since my site is not in english. I accomplished something similar with the GridPagerItem to change the PageSizeLabel, but now I need to do the same for this.

For the GridPagerItem I am using the following code and it works, maybe what I need for the "Click here to sort" is something similar? :

protected void GridUltimosConteudos_ItemDataBound(object sender, GridItemEventArgs e)
{

    if (e.Item is GridPagerItem)
    {
        Label lblPageSize = (Label)e.Item.FindControl("ChangePageSizeLabel");
        lblPageSize.Text = "Itens por página:";
    }

}



Thanks!
Marta

11 Answers, 1 is accepted

Sort by
0
Marta
Top achievements
Rank 1
answered on 24 Jun 2009, 04:44 PM
I managed to get half way there with:

        if (e.Item is GridHeaderItem)
        {
                GridHeaderItem header = (GridHeaderItem)e.Item;
                header["Titulo"].ToolTip = "Custom Text";

        }



The problem is that this text only adds a tooltip the the entire header of the column and not to the title text of the column (which in my case is a hyperlink) I can't seem to access it and so the text "click here to sort" remains there...

Does anyone have any suggestions, please...?
0
Marta
Top achievements
Rank 1
answered on 24 Jun 2009, 05:11 PM
After many tries and a lot of research, I finally found the solution, it's really simple!

GridUltimosConteudos.SortingSettings.SortToolTip =

"Clique para ordenar";

 

0
Pavlina
Telerik team
answered on 25 Jun 2009, 07:19 AM
Hello Marta,

I am happy to hear you have found a solution for your case. Do not hesitate to contact us if any issues arise.
Additionally, for more information you can check this help article:
Localizing the grid messages

Greetings,
Pavlina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
kollam2003
Top achievements
Rank 1
answered on 19 Jul 2009, 08:21 AM
Can we add separate tooltips for sort for  each column
0
Shinu
Top achievements
Rank 2
answered on 20 Jul 2009, 06:36 AM
Hi Kollam2003,

Try out the following code snippet in the ItemDataBound event  to set custom sort tooltip for individual column.

CS:
 
 
 protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridHeaderItem) 
        { 
            GridHeaderItem header = (GridHeaderItem)e.Item; 
 
            LinkButton lnkbtn1 = (LinkButton)header["ProductName"].Controls[0]; 
            lnkbtn1.ToolTip = "Sort the Name Column"
 
            LinkButton lnkbtn2 = (LinkButton)header["ProductID"].Controls[0]; 
            lnkbtn2.ToolTip = "Sort the ID Column"
 
        } 
    } 


Shinu
0
Paweł J
Top achievements
Rank 1
answered on 01 Sep 2009, 09:13 AM
LinkButton lnkbtn1 = (LinkButton)header["ProductName"].Controls[0];

Telerik.Web.UI.GridException: Cannot find a cell bound to column name 'ProductName''
0
Princy
Top achievements
Rank 2
answered on 07 Sep 2009, 07:18 AM
Hello Pawel,

You should be replacing 'ProductName' with the UniqueName of the required column in your grid. If you are using AutoGenerated columns then the column UniqueName would be same as the DataField of the column in your database, whereas if you are adding columns manually then you can set the UniqueName property of the corresponding column manually. Hence, you should be able to avoid the exception.

Hope this helps..
-Princy.
0
Paweł J
Top achievements
Rank 1
answered on 07 Sep 2009, 12:17 PM
no joke !!

Maybe i should be more specific. Ofc I assigned a Unique Name of the column and Im calling it as you said. This is aspx part


<MasterTableView DataKeyNames="idNumer" HierarchyLoadMode="Client" TableLayout="Fixed" BorderStyle="None" > 
                <Columns> 
                    <telerik:GridBoundColumn UniqueName="idNrRej" DataField="idNrRej" HeaderText="Nr Rejestracyjny" 
                        ShowFilterIcon="False"

this is cs part

protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridHeaderItem) 
        { 
            GridHeaderItem header = (GridHeaderItem)e.Item; 
            LinkButton lnkbtn1 = (LinkButton)header["idNrRej"].Controls[0];  
        } 
    } 

and the funny part is that when debugging I saw that program enters the cs part twice. First time all is ok (the column is found), the second time I get an error
0
Shinu
Top achievements
Rank 2
answered on 08 Sep 2009, 04:26 AM
Hi Pawel,

I would suggest you to set the Name property for the Master table and try the following approach.

ASPX:
 
 
<MasterTableView DataKeyNames="idNumer" HierarchyLoadMode="Client" Name="Master" TableLayout="Fixed" BorderStyle="None" >  
                <Columns>  
                    <telerik:GridBoundColumn UniqueName="idNrRej" DataField="idNrRej" HeaderText="Nr Rejestracyjny"  
                        ShowFilterIcon="False">  

CS:
 
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)  
    {  
       
     if ((e.Item is GridHeaderItem)&&(e.Item.OwnerTableView.Name=="Master")
        { 
            GridHeaderItem header = (GridHeaderItem)e.Item; 
            LinkButton lnkbtn1 = (LinkButton)header["idNrRej"].Controls[0]; 
        }  
 
    }  
 

Thanks
Shinu

0
Paweł J
Top achievements
Rank 1
answered on 09 Sep 2009, 07:49 AM
that worked, thanks.
Make sure to include this info in tutorials
0
Shinu
Top achievements
Rank 2
answered on 09 Sep 2009, 08:05 AM
Hi Pawel,

This error usually occurs when working with hierarchical Grid. Since the ItemDataBound event gets raised at whatever level of the RadGrid's tables are getting bound, we need some kind of check to make sure which Detail table or master table we're dealing with.

Here is a help article which explains the most common mistakes that can happen. Read through the seventh point which explains how to handle the ItemDataBound or ItemCreated events.
Most Common Mistakes


You can also have a look at the following help article which explains ho to distinguish grid rows in hierarchy on ItemCreated/ItemDataBound.
Distinguish grid rows in hierarchy on ItemCreated/ItemDataBound

Regards
Shinu
Tags
Grid
Asked by
Marta
Top achievements
Rank 1
Answers by
Marta
Top achievements
Rank 1
Pavlina
Telerik team
kollam2003
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Paweł J
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or