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

Changing delete text on RADGrid autogenerated column

8 Answers 395 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Jason Thacker
Top achievements
Rank 1
Jason Thacker asked on 26 Aug 2009, 06:08 PM
Is there any way of changing the default "delete" "edit" "insert" "cancel" etc. text on a RADGrid with auto-generated delete and edit columns? I need to change these to a non-english language and I am struggling with trying to apply localization to the RADGrid control.

Thanks in advance,

Jason

8 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 27 Aug 2009, 05:34 AM
Hello Jason,

You can customize the Edit and Delete texts as shown below:
c#:
  protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridDataItem) 
        { 
            GridDataItem item = (GridDataItem)e.Item; 
            ((LinkButton)item["AutoGeneratedEditColumn"].Controls[0]).Text = "CustomEdit"
            ((LinkButton)item["AutoGeneratedDeleteColumn"].Controls[0]).Text = "CustomDelete"
        } 
    } 

And to customize the Insert , Update and Cancel buttons, you can try out the following:
aspx:
    <telerik:RadGrid ID="RadGrid1" DataSourceID="SqlDataSource1"   runat="server" AutoGenerateDeleteColumn="true" AutoGenerateEditColumn="true" OnItemDataBound="RadGrid1_ItemDataBound"
                <MasterTableView DataSourceID="SqlDataSource1" EditMode="InPlace" CommandItemDisplay="Top"
                      <EditFormSettings> 
                        <EditColumn UniqueName="EditCommandColumn1" InsertText="CustomInsert" CancelText="CustomCancel" UpdateText="CustomUpdate" > 
                        </EditColumn> 
                      </EditFormSettings> 
                         ....

Thanks
Princy.
0
Luigi
Top achievements
Rank 1
answered on 14 May 2010, 04:51 PM

Please,

Could I get the example in VB?

thank you very much
Luigi
0
Daniel
Telerik team
answered on 14 May 2010, 09:02 PM
Hello Luigi,

You can use our online code converter to convert your code-snippets.

VB:
Protected Sub RadGrid1_ItemDataBound(sender As Object, e As GridItemEventArgs) Handles RadGrid1.ItemDataBound
    If TypeOf e.Item Is GridDataItem Then
        Dim item As GridDataItem = DirectCast(e.Item, GridDataItem)
        DirectCast(item("AutoGeneratedEditColumn").Controls(0), LinkButton).Text = "CustomEdit"
        DirectCast(item("AutoGeneratedDeleteColumn").Controls(0), LinkButton).Text = "CustomDelete"
    End If
End Sub

Regards,
Daniel
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.
0
antonio
Top achievements
Rank 1
answered on 14 Dec 2010, 09:14 PM
Hi,

I tested this solution and works fine, but exist some way to change this text only for some row values???

For example:
            
           id            name             depto
edit      1             Terry            Sales
view    2             George         Marketing
view    3             Christine      Marketing

edit      4             Robert          Sales

The thext "edit" only change to "view", when value for depto field is "Marketing".

Is this posible????
0
Sebastian
Telerik team
answered on 15 Dec 2010, 09:10 AM
Hello antonio,

Try the following code modification to see whether this produces the desired result:

Protected Sub RadGrid1_ItemDataBound(sender As Object, e As GridItemEventArgs) Handles RadGrid1.ItemDataBound' provided that your depto column has UniqueName="depto"
    If TypeOf e.Item Is GridDataItem Then
        Dim item As GridDataItem = DirectCast(e.Item, GridDataItem)
        If item["depto"].Text = "Marketing" Then
           DirectCast(item("AutoGeneratedEditColumn").Controls(0), LinkButton).Text = "view" 
        End If
End Sub

Regards,
Sebastian
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
antonio
Top achievements
Rank 1
answered on 15 Dec 2010, 04:27 PM
Thanks Sebastian,

the solution works fine!


Regards,
Antonio Bastida Cruz
0
Chris
Top achievements
Rank 1
answered on 03 Jun 2015, 05:14 PM

I get an error on the "If item["depto"]" item cannot be converted to boolean. Otherwise, this looks to be the solution I am in search of, but cant get past this item value. Anyone know what the issue may be?

0
Eyup
Telerik team
answered on 08 Jun 2015, 02:19 PM
Hi Chris,

Generally, you will need to use the Controls[0] approach in order to access any autogenerated column controls:
http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/rows/accessing-cells-and-rows

If you have different requirements or further instructions, please elaborate on your specific scenario so we can provide you with a more accurate solution.

Regards,
Eyup
Telerik
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 Feedback Portal and vote to affect the priority of the items
Dhaval
Top achievements
Rank 1
commented on 19 May 2023, 06:50 AM

Hi Eyup/Telerik team,

I have a slightly different issue with the Autogenerated Delete column in the 2-level hierarchical Radgrid. I want to position the Autogenerated delete column in the end of all the dynamic columns of a datasource.

Can you please help me as in how to align the Autogenerated delete column at the last of all the dynamic columns in Parent and Child both the tables?

Thanks & Regards,

Dhaval Doshi.

 

Doncho
Telerik team
commented on 23 May 2023, 12:28 PM

Hi Dhaval,

By default, the AutoGeneratedDeleteColumn is rendered after any columns that are created declaratively in the Grid markup. Yet, the same is rendered before the AutoGeneratedColumns.

If you want to control the order of all the rendered columns you will need to declare them all in the markup of the RadGrid ordered in the desired way and avoid using the AutoGeneratedColumns.

One more option is to manually generate the structure of the Grid programmatically and create and add the Columns to the TableView in the desired order but this approach could get quite tricky when it comes to hierarchical RadGrid, see 

Tags
Ajax
Asked by
Jason Thacker
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Luigi
Top achievements
Rank 1
Daniel
Telerik team
antonio
Top achievements
Rank 1
Sebastian
Telerik team
Chris
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or