I have created the custom grid with one custom column(Products) by renderer method which shows product name. When I tried to apply sorting it looks the custom table in which other columns exists but this field is not available in that table as it rendered, later it shows application went wrong error.

enter image description here


    <column name="products" class="Module\Name\Ui\Component\Listing\Column\Products">
                <argument name="data" xsi:type="array">
                    <item name="config" xsi:type="array">
                        <item name="indexField" xsi:type="string">pdt_id</item>
                        <item name="label" xsi:type="string" translate="true">Products</item>
                        <item name="sortOrder" xsi:type="number">200</item>


namespace Module\Name\Ui\Component\Listing\Column;

use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;
use Magento\Framework\View\Element\UiComponent\ContextInterface;
use Magento\Framework\View\Element\UiComponentFactory;
use Magento\Ui\Component\Listing\Columns\Column;

 * Class BlockActions
class Products extends Column
     * @var Magento\Sales\Model\Order
    protected $_productCollectionFactory;

     * Constructor
     * @param ContextInterface $context
     * @param UiComponentFactory $uiComponentFactory
     * @param UrlInterface $urlBuilder
     * @param array $components
     * @param array $data
    public function __construct(
        ContextInterface $context,
        UiComponentFactory $uiComponentFactory,
        CollectionFactory $product,
        array $components = [],
        array $data = []
    ) {
        $this->_productCollectionFactory = $product;
        parent::__construct($context, $uiComponentFactory, $components, $data);

     * Prepare Data Source
     * @param array $dataSource
     * @return array
    public function prepareDataSource(array $dataSource)
        if (isset($dataSource['data']['items'])) {
            foreach ($dataSource['data']['items'] as & $item) {
                $pdtNames = array();           
                $productCollection = $this->_productCollectionFactory->create();
                $productCollection->addAttributeToFilter('developer',array('eq' =>$item['name']));

                foreach ($productCollection as $collection){
                    $pdtNames[] = $collection->getName();
                $partnerPdts = implode(', ', $pdtNames);
                $item['partners_products'] = $partnerPdts;

        return $dataSource;
  • You create the grid via Grid container or UI component? Please give us these code lines of your custom column(Product) – Khoa TruongDinh May 5 '16 at 10:34
  • Shared the code. – saravanavelu May 6 '16 at 9:07
  • created the grid via UI component – saravanavelu May 6 '16 at 9:14
  • @saravanavelu are you able to change the sort order! I am facing same problem – Bhupendra Jadeja Jul 6 '16 at 6:03
  • I have added tht column to custom table and it was working. May I know in which grid you facing this issue? – saravanavelu Jul 6 '16 at 6:05
  1. Remove the corresponding row in the ui_bookmark table. This fixed the problem for me.
  2. Clean your cache after doing that.

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.