How do I add a custom button on a listgrid toolbar?
To add a custom button/action to a listgrid we need to create a new ListGridAction and add it to the listgrid. We have a good sample in the BLC codebase with the Generate Skus action on the AdminProductController.
//Skus have a specific toolbar action to generate Skus based on permutations EntityForm form = (EntityForm) model.asMap().get("entityForm"); ListGridAction generateSkusAction = new ListGridAction(ListGridAction.GEN_SKUS).withDisplayText("Generate_Skus") .withIconClass("icon-fighter-jet") .withButtonClass("generate-skus") .withUrlPostfix("/generate-skus") .withActionUrlOverride("/product/" + id + "/additionalSkus/generate-skus"); ListGrid skusGrid = form.findListGrid("additionalSkus"); if (skusGrid != null) { skusGrid.setCanFilterAndSort(false); } ListGrid productOptionsGrid = form.findListGrid("productOptions"); if (productOptionsGrid != null) { productOptionsGrid.addToolbarAction(generateSkusAction); }