0

I want to show data from 2 different objects inside an SLDS Page Header

For the page header I use <ul class="slds-page-header__detail-row">

For the data - I use lightning:recordViewForm

If I get data from one object - all looks and works well :

<lightning:recordViewForm recordId="a1IW0000001CGSbMAO" objectApiName="Budget__c">
    <ul class="slds-page-header__detail-row">
        <li class="slds-page-header__detail-block">
            <lightning:outputField fieldName="Id" />
        </li>
        <li class="slds-page-header__detail-block">
            <lightning:outputField fieldName="Name" />
        </li>
    </ul>
</lightning:recordViewForm>

enter image description here

When I want to get data from 2 different objects, I tried many different things and could not find a way to show it OK:

First try

I tried to put the <ul> element outside the lightning:recordViewForm, and then all the css gets messed up:

<ul class="slds-page-header__detail-row">
    <lightning:recordViewForm recordId="a1IW0000001CGSbMAO" objectApiName="Budget__c">
        <li class="slds-page-header__detail-block">
            <lightning:outputField fieldName="Id" />
        </li>
        <li class="slds-page-header__detail-block">
            <lightning:outputField fieldName="Name" />
        </li>
    </lightning:recordViewForm>
    <lightning:recordViewForm recordId="a1HW0000002vh5xMAA" objectApiName="Payment__c">
        <li class="slds-page-header__detail-block">
            <lightning:outputField fieldName="Id" />
        </li>
        <li class="slds-page-header__detail-block">
            <lightning:outputField fieldName="Name" />
        </li>
    </lightning:recordViewForm>
</ul>

enter image description here

Second try

I tried to put 2 <ul> elements and it looks nice but it creates 2 lines:

<lightning:recordViewForm recordId="a1IW0000001CGSbMAO" objectApiName="Budget__c">
    <ul class="slds-page-header__detail-row">
        <li class="slds-page-header__detail-block">
            <lightning:outputField fieldName="Id" />
        </li>
        <li class="slds-page-header__detail-block">
            <lightning:outputField fieldName="Name" />
        </li>
    </ul>
</lightning:recordViewForm>
<lightning:recordViewForm recordId="a1HW0000002vh5xMAA" objectApiName="Payment__c">
    <ul class="slds-page-header__detail-row">
        <li class="slds-page-header__detail-block">
            <lightning:outputField fieldName="Id" />
        </li>
        <li class="slds-page-header__detail-block">
            <lightning:outputField fieldName="Name" />
        </li>
    </ul>
</lightning:recordViewForm>

enter image description here

Third try

I have tried to put these 2 <ul> in slds-grid so it would display in one line but it does not space up the fields:

<div class="slds-grid">
    <div class="slds-col">
        <lightning:recordViewForm recordId="a1IW0000001CGSbMAO" objectApiName="Budget__c">
            <ul class="slds-page-header__detail-row">
                <li class="slds-page-header__detail-block">
                    <lightning:outputField fieldName="Id" />
                </li>
                <li class="slds-page-header__detail-block">
                    <lightning:outputField fieldName="Name" />
                </li>
                <li class="slds-page-header__detail-block">
                    <lightning:outputField fieldName="Description__c" />
                </li>
                <li class="slds-page-header__detail-block">
                    <lightning:outputField fieldName="Version__c" />
                </li>
                <li class="slds-page-header__detail-block">
                    <lightning:outputField fieldName="LastModifiedById" />
                </li>
                <li class="slds-page-header__detail-block">
                    <lightning:outputField fieldName="CreatedById" />
                </li>
            </ul>
        </lightning:recordViewForm>
    </div>
    <div class="slds-col">
        <lightning:recordViewForm recordId="a1HW0000002vh5xMAA" objectApiName="Payment__c">
            <ul class="slds-page-header__detail-row">
                <li class="slds-page-header__detail-block">
                    <lightning:outputField fieldName="Id" />
                </li>
                <li class="slds-page-header__detail-block">
                    <lightning:outputField fieldName="Name" />
                </li>
            </ul>
        </lightning:recordViewForm>
    </div>
</div>

enter image description here

I have tried to play around a lot with the chrome dev tool so it will align nicely but couldn't find any solution that would be OK

Is there any solution to display more than one lightning:recordViewForm object inside SLDS Page Header?

1
  • I dotn really see any attempt to set a size on your rows for each 'form' to occupy within the header, for example, using a grid, but also leveraging slds-col slds-size_1-of-2 or using lightning:layout's with layout:item size attributes
    – glls
    Commented Nov 14, 2018 at 13:31

1 Answer 1

1

The best you can do is use a grid:

<lightning:layout>
  <lightning:layoutItem size="6">
    ...
  </lightning:layoutItem>
  <lightning:layoutItem size="6">
    ...
  </lightning:layoutItem>
</lightning:layout>

Note: if the fields are different sizes, the fields may not line up, but they will be side by side.

4
  • Thanks, it is better than what I have tried, but still does not behave well, especially when the screen gets smaller Commented Nov 14, 2018 at 13:58
  • @ItaiShmida you may need to use smallDeviceSize/mediumDeviceSize to eventually squeeze into a one-column-per-line mode instead. It's not reasonable to fit two columns on a phone's portrait mode. Check out lightning:layoutItem for the various options.
    – sfdcfox
    Commented Nov 14, 2018 at 14:00
  • OK, but I do not want 2 columns - I want to display a list of fields in 1 row Commented Nov 14, 2018 at 14:01
  • There's no SLDS for this design, so you'll probably have to try and figure out your own, probably involving force:recordData and rendering your own page header.
    – sfdcfox
    Commented Nov 14, 2018 at 14:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .