# Adding a Custom Button in the Grid's ToolBar

## Environment

<table>
	<tbody>
		<tr>
			<td>Product Version</td>
			<td>2020.1.406</td>
		</tr>
		<tr>
			<td>Product</td>
			<td>Telerik UI for ASP.NET MVC Grid</td>
		</tr>
	</tbody>
</table>

## Description

Is there a way to create one button in the toolbar right aligned from the other buttons that opens a Telerik UI for ASP.NET MVC Window in the Grid for ASP.NET MVC?

## Solution

To add a custom button:

1. Include a [custom command button](https://www.telerik.com/aspnet-mvc/documentation/api/kendo.mvc.ui.fluent/gridtoolbarcommandfactory#custom) in the toolbar.

   ```razor
       // Toolbar in the Grid
       .ToolBar(e => {
           e.Pdf();
           e.Excel();
           e.Custom().Text("Instructions").HtmlAttributes(new { id = "customButton", @class="flexAlignRight" });
       })
   ```

2. On the click event of the button, add the logic to [open the Telerik UI for ASP.NET MVC Window](https://docs.telerik.com/kendo-ui/api/ui/window/methods/open).

   ```javascript
       $("#grid").on("click", "#customButton", function (e) {
           e.preventDefault();  //prevents postback

           var window = $("#window").data("kendoWindow");
           window.open();
       });
   ```

3. Finally, add some style to right align the Telerik UI for ASP.NET MVC Button.

   ```css
       .flexAlignRight {
           margin-left: auto;
       }
   ```

## More ASP.NET MVC Grid Resources

* [ASP.NET MVC Grid Documentation](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/data-management/grid/overview)

* [ASP.NET MVC Grid Demos](https://demos.telerik.com/aspnet-mvc/grid/index)

* [ASP.NET MVC Grid Product Page](https://www.telerik.com/aspnet-mvc/grid)

* [Telerik UI for ASP.NET MVC Video Onboarding Course (Free for trial users and license holders)](https://www.telerik.com/aspnet-mvc/documentation/getting-started/video-onboarding)

* [Telerik UI for ASP.NET MVC Forums](https://www.telerik.com/forums/aspnet-mvc)

## See Also

* [Client-Side API Reference of the Grid for ASP.NET MVC](https://docs.telerik.com/kendo-ui/api/ui/grid)
* [Server-Side API Reference of the Grid for ASP.NET MVC](https://docs.telerik.com/aspnet-mvc/api/grid)
* [Telerik UI for ASP.NET MVC Breaking Changes](https://www.telerik.com/aspnet-mvc/documentation/backwards-compatibility/2023-backwards-compatibility)
* [Telerik UI for ASP.NET MVC Knowledge Base](https://docs.telerik.com/aspnet-mvc/knowledge-base)
