Page 1 of 1

Adding custom field in ListGrid

Posted: Tue Nov 08, 2016 3:48 am
by smabrouk
Hi all,

When i navigate to Catalog -> Categories in Admin site all Categories appears in a table with Name and Url columns all i want to do is to add the Category id in a new column.
Actually i followed this documentation http://www.broadleafcommerce.com/docs/core/current/broadleaf-concepts/admin/admin-metadata-overrides and i used XML-based overrides method:

I added this to my applicationContext:

Code: Select all

<beans xmlns="http://www.springframework.org/schema/beans"
       ...
       ...
       ...
       xmlns:mo="http://schema.broadleafcommerce.org/mo"
       ...
       xsi:schemaLocation="
          http://www.springframework.org/schema/beans
          http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
          ...
          ...
          http://schema.broadleafcommerce.org/mo
          http://schema.broadleafcommerce.org/mo/mo-3.0.xsd">


and i added this overrides as well in applicationContext:

Code: Select all

    <mo:override id="blMetadataOverrides">
        <mo:overrideItem ceilingEntity="org.broadleafcommerce.core.catalog.domain.Category">

            <mo:field name="url">
                <mo:property name="friendlyName" value="CategoryUrl" />
                <mo:property name="prominent" value="false" />
                <mo:property name="excluded" value="true" />
            </mo:field>

            <mo:field name="id">
                <mo:property name="visibility" value="VISIBLE_ALL" />
                <mo:property name="friendlyName" value="CategoryId" />
                <mo:property name="prominent" value="true" />
                <mo:property name="excluded" value="false" />
            </mo:field>
        </mo:overrideItem>
    </mo:override>


The result is id field is not displayed as column in Category table but i was able to hide url column.

How can i do that displaying id column in Category table?

Thanks.

Re: Adding custom field in ListGrid

Posted: Tue Nov 08, 2016 10:21 am
by jocanas
Hi smabrouk,

The id's follow a different pattern since they are explicitly hidden. This was chosen because for the most part, the BLC specific IDs tend to be meaningless and implementors need their own product/category IDs.

Having said that, you can enable them by setting the following property in one of your properties files:

Code: Select all

listGrid.forceShowIdColumns=true


Just note that this enables all IDs.