New to Telerik UI for ASP.NET CoreStart a free 30-day trial

Adding Command Buttons as Icons with No Text

Environment

Product Version2019.2.619
ProductTelerik UI for ASP.NET Core Grid

Description

How can I set a command button in the Telerik UI Grid that contains only an icon and no text?

Solution

Use either of the following approaches:

  • Use CSS to style the Edit button by setting the .k-grid-edit-command CSS of the button as desired. Include the following configuration in the k-button-icon class.

    CSS
    .k-grid tbody .k-grid-edit-command {
    	min-width: 0;
    	width: calc(2px + .75rem + 1.5em);
    	height: calc(2px + .75rem + 1.5em);
    	padding: .375rem;
    }
    
    .k-grid tbody .k-grid-edit-command .k-icon{
    	margin: 0;
    }
  • Create a custom template for the Edit button with an additional class. By using the onclick event handler, set the editRow method for the specific Grid row.

    Razor
    .Columns(columns =>
    {
    	columns.Bound(c => c.ProductName).Width(150);
    	columns.Bound(c => c.Discontinued).Width(75);
    	columns.Command(command => { command.Edit().Template("<button type=\"button\" class=\"k-button k-button-icon edit\"><span class=\"k-icon k-i-edit\"></span></button>"); command.Destroy(); }).Width(300);
    })

More ASP.NET Core Grid Resources

See Also