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

Css to change edit/delete icon?

1 Answer 117 Views
Grid
This is a migrated thread and some comments may be shown as answers.
AereoN
Top achievements
Rank 1
AereoN asked on 13 Jan 2010, 03:06 AM
Is there a way for me to alter the icons in the grid without having to specify them in each and every grid design mode?

1 Answer, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 14 Jan 2010, 11:04 AM
Hi AereoN,

You can use CSS classes and external styles to define the appearance of all edit / delete buttons. Here is an example with some randomly picked images from Google:

<%@ Page Language="C#" %>
<%@ Import Namespace="System.Data" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
 
<script runat="server">
 
    protected void RadGrid_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
    {
        DataTable dt = new DataTable();
        DataRow dr;
        int colsNum = 3;
        int rowsNum = 3;
        string colName = "Column";
 
        for (int j = 1; j <= colsNum; j++)
        {
            dt.Columns.Add(String.Format("{0}{1}", colName, j));
        }
 
        for (int i = 1; i <= rowsNum; i++)
        {
            dr = dt.NewRow();
 
            for (int k = 1; k <= colsNum; k++)
            {
                dr[String.Format("{0}{1}", colName, k)] = String.Format("{0}{1} Row{2}", colName, k, i);
            }
            dt.Rows.Add(dr);
        }
 
        (sender as RadGrid).DataSource = dt;
    }
     
</script>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 
<head runat="server">
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<title>RadControls</title>
<style type="text/css">
 
.MyDeleteButton,
.MyEditButton
{
    border:0;
    background-color:transparent;
    background-repeat:no-repeat;
    background-position:center center;
    width:20px;
    height:20px;
    cursor:pointer;
}
 
.MyDeleteButton
{
}
 
.MyEditButton
{
}
 
</style>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
 
<telerik:RadGrid
    ID="RadGrid1"
    runat="server"
    Width="400px"
    OnNeedDataSource="RadGrid_NeedDataSource">
    <MasterTableView>
        <Columns>
            <telerik:GridButtonColumn HeaderText="Delete" CommandName="Delete" ButtonType="PushButton" ButtonCssClass="MyDeleteButton" Text=" " />
            <telerik:GridButtonColumn HeaderText="Edit" CommandName="Edit" ButtonType="PushButton" ButtonCssClass="MyEditButton" Text=" " />
        </Columns>
    </MasterTableView>
</telerik:RadGrid>
 
</form>
</body>
</html>


All the best,
Dimo
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Grid
Asked by
AereoN
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Share this question
or