How To: Remove Add Button from a Grid
You can override GetButtons() method in MyGrid.cs (which is under MyProject.Script).
This removes all buttons (including refresh):
public class MyGrid : EntityGrid<MyRow>
{
//...
protected override List<ToolButton> GetButtons()
{
return new List<ToolButton>();
}
}
To remove add button with its index (0 - first button):
public class MyGrid : EntityGrid<MyRow>
{
//...
protected override List<ToolButton> GetButtons()
{
var buttons = base.GetButtons();
buttons.RemoveAt(0);
return buttons;
}
}
Working with hard coded indexes is a bad code smell
Or return a new list with your button list:
public class MyGrid : EntityGrid<MyRow>
{
//...
protected override List<ToolButton> GetButtons()
{
var buttons = new List<ToolButton>();
buttons.Add(new ToolButton
{
Title = "My New Button",
CssClass = "my-new-button",
OnClick = delegate {
// ...
}
});
buttons.Add(NewRefreshButton(noText: true));
return buttons;
}
}