SalesforceLabs / EnhancedLightningGrid

Component that allows you to sort and filter data within the Lightning Experience. Use as a replacement for a Related List, or create a new grid that shows results from a custom query.
BSD 3-Clause "New" or "Revised" License
136 stars 96 forks source link

Numbers should be right-aligned #10

Open lawgoch opened 6 years ago

lawgoch commented 6 years ago

The base sdgDatagridCell.cmp has the layout for the individual cells:

<td data-label="{#v.renderfield.FieldLabel}" class="pullleft pullup">
    <div class="slds-truncate">{!v.body}</div>
</td>

There is no included definition for the pullleft class, but text defaults to left-aligned, so that's the default for all fields, with no way to customize or change.

This can be fixed quickly with a quick customization - add an attribute for cellStyleClass to the .cmp file and set it in the contoller based on field type.

New sdgDatagridCell.cmp:

{!v.body}
And for each type that needs to be aligned right, in the controller (I would use Percent, Integer, Currency, and Double): case "INTEGER": helper.renderNumber(component, datachunk, 0); cmp.set("v.cellStyleClass", "slds-text-align_right pullup"); break;