How do I show IDs in the admin's listgrids?
Displaying the entity IDs
is driven by the listGrid.forceShowIdColumns
property. Broadleaf auto hides them all by default since for the most part, the broadleaf ID tends to not matter to most users. However, this can be enabled by setting the property to `true` to show them. Just note that this affects ALL list grids. This works off of the following code:
org/broadleafcommerce/common/web/expression/PropertiesVariableExpression.java
https://github.com/BroadleafCommerce/BroadleafCommerce/blob/broadleaf-5.2.5-GA/common/src/main/java/org/broadleafcommerce/common/web/expression/PropertiesVariableExpression.java
That code is used in listGrid.html:
https://github.com/BroadleafCommerce/BroadleafCommerce/blob/broadleaf-5.2.5-GA/admin/broadleaf-open-admin-platform/src/main/resources/open_admin_style/templates/components/listGrid.html#L67
The code above can also be triggered via a request parameter. If you add ?showIds=true to the end of your request it should display them. For example:
.../admin/product?showIds=true
If you need to be more specific and ONLY show the IDs on one section (i.e. just show the IDs on the products) you can do so by extending the corresponding AdminController. In this example you can the AdminProductController
and override the viewEntityList
method.
@Override public String viewEntityList(HttpServletRequest request, HttpServletResponse response, Model model, Map<String, String> pathVars, MultiValueMap<String, String> requestParams) throws Exception { String result = super.viewEntityList(request, response, model, pathVars, requestParams); ListGrid listGrid = (ListGrid) model.asMap().get("listGrid"); listGrid.setHideIdColumn(Boolean.FALSE); return result; } }