I have created a custom grid in admin for "Seller Commission". Now, I want to show total commission earned, so need to add a row at the end of the grid which should say "Total Amount". Please help.


You can use renderer to show custom values or to calculate and show commission value.

For Example in your uicomponent grid xml

<column name="commission" class="Vender\Modulename\Ui\Component\Listing\Column\Commission">
    <argument name="data" xsi:type="array">        
        <item name="config" xsi:type="array">
            <item name="filter" xsi:type="string">text</item>
            <item name="sorting" xsi:type="string">asc</item>
            <item name="label" translate="true" xsi:type="string">Commission</item>

And Your Renderer File


namespace Vender\Modulename\Ui\Component\Listing\Column;

class Commission extends \Magento\Ui\Component\Listing\Columns\Column {

     * @var \Magento\Directory\Api\CountryInformationAcquirerInterface
    protected $countryInformation;

     * @param \Magento\Framework\View\Element\UiComponent\ContextInterface $context
     * @param \Magento\Framework\View\Element\UiComponentFactory $uiComponentFactory
     * @param array $components
     * @param array $data
    public function __construct(
        \Magento\Framework\View\Element\UiComponent\ContextInterface $context,
        \Magento\Framework\View\Element\UiComponentFactory $uiComponentFactory,
        array $components = [],
        array $data = []
        $this->countryInformation = $countryInformation;
        parent::__construct($context, $uiComponentFactory, $components, $data);

     * Prepare Data Source
     * @param array $dataSource
     * @return array
    public function prepareDataSource(array $dataSource) {
        if (isset($dataSource['data']['items'])) {
            $fieldName = $this->getData('name');
            foreach ($dataSource['data']['items'] as & $item) {
                //do your stuff and set value of commission in here

        return $dataSource;
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.