cancel
Showing results for 
Search instead for 
Did you mean: 

How to display relational attribute in list view of Backoffice?

0 Kudos
1,895

I have two items, ItemA and ItemB and there is one to many relation between them. I have a requirement to display the attribute of ItemB in ItemA.

       <itemtype code="ItemA"
             jaloclass="com.xyz.core.staff.jalo.StaffInformation">
             <deployment table="staffinformation" typecode="20707" />
             <attributes>
                 <attribute type="java.lang.String" qualifier="name">
                     <modifiers optional="false" />
                     <persistence type="property" />
                 </attribute>
             </attributes>
         </itemtype>    

      <itemtype code="ItemB" extends="AbstractContactDetails"
             jaloclass="com.xyz.core.contact.jalo.EContactInfo">
             <attributes>            
                 <attribute type="java.lang.String" qualifier="emailAddress">
                     <modifiers unique="true" />
                     <persistence type="property" />
                 </attribute>
             </attributes>
         </itemtype>
 
        <relation code="ItemAToItemB" autocreate="true"
         generate="false" localized="false">
         <sourceElement qualifier="itemA" type="ItemA"
             cardinality="one">
             <modifiers />
         </sourceElement>
         <targetElement qualifier="itemB" type="ItemB"
             cardinality="many">
             <modifiers partof="true" />
         </targetElement>
 </relation>

So i need to display emailAddress in list view of ItemA

I tried accessing attribute through qualifier of targetElement i.e itemB.emailAddress and also tried giving base config for ItemB.

But it didnt worked. Please Suggest

Thanks,

Accepted Solutions (0)

Answers (4)

Answers (4)

former_member620692
Active Contributor

Since you want to render an attribute from the target item in a relation, you do not need any custom renderer. You can do it as follows:

 <context type="ItemA" component="listview">
     <list:list-view xmlns:list="http://www.hybris.com/cockpitng/component/listView">
         <list:column qualifier="name"/>
         <list:column qualifier="itemB"/>
     </list:list-view>
 </context>
 
 <context type="ItemB" component="base">
     <y:base xmlns:y="http://www.hybris.com/cockpit/config/hybris">
         <y:labels>
             <y:label>emailAddress</y:label>
         </y:labels>
     </y:base>
 </context>

Given below is the screenshot of what you see in backoffice:

former_member632755
Active Contributor

Hi,

could you share your configuration of the List View that does not work? You can always use a custom cell renderer for a column and code it in Java.

Cheers, Wojtek

0 Kudos

Hi Wojtek,

List view is as follows:

     <list:list-view xmlns:list="http://www.hybris.com/cockpitng/component/listView">
         <list:column qualifier="name">
         <list:column qualifier="itemB.emailAddress" />    
     </list:list-view>
 </context>
Former Member
0 Kudos

Hi All, If you want to fetch the value from other type other than the context one then, you may have to write renderer class to fetch the value of that attribute. For instance in above code you have to write one java class which implements WidgetComponentRenderer and the spring name can be used to define that


  <list:list-view xmlns:list="http://www.hybris.com/cockpitng/component/listView">
          <list:column qualifier="name">
          <list:column qualifier="emailAddress" spring-bean="emailAddressRenderer"  label="Email Address" />    
      </list:list-view>
  </context>

sumit_rajan
Associate
Associate
0 Kudos

Great Hamid

Former Member
0 Kudos

Any suggestions for the above question? I am also facing the same issue.