Adding custom field in ListGrid

Information and discussions on the Broadleaf Commerce Admin Tool

Moderator: jocanas

smabrouk
Newbie
Newbie
Posts: 1
Joined: Fri Nov 04, 2016 2:35 am

Adding custom field in ListGrid

Postby smabrouk » Tue Nov 08, 2016 3:48 am

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.
Attachments
Screen Shot 2016-11-08 at 09.46.52.png
Screen Shot 2016-11-08 at 09.46.52.png (325.2 KiB) Viewed 4315 times

jocanas
Newbie
Newbie
Posts: 14
Joined: Mon Jan 23, 2012 4:40 pm

Re: Adding custom field in ListGrid

Postby jocanas » Tue Nov 08, 2016 10:21 am

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.


Return to “Broadleaf Commerce Admin”

Who is online

Users browsing this forum: No registered users and 1 guest