I created my custom module with admin grid, then i tried to add order increment id to my custom grid by altering the grid collection with alias name.

The order id is displaying in grid. Now, if I try to filter by increment_id , then it throws an error. Without alias its working fine, if i add alias and try to filter at that time it throws the error.

Following is my code:

     <column name="order_id">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="filter" xsi:type="string">text</item>
                    <item name="filter_index" xsi:type="string">o.increment_id</item>
                    <item name="add_field" xsi:type="boolean">false</item>
                    <item name="label" xsi:type="string" translate="true">Order ID</item>
                    <item name="sortOrder" xsi:type="number">75</item>


protected function _initSelect()
            ['o' => 'sales_order_grid'],
            "(o.entity_id = main_table.id)",
                'o.increment_id as order_id'
        return $this;

So please tell how can I add the filter_index in magento2 with UI Component ?


I got it by using the addFiltertoMap

Which is defined in


protected function _construct()
| improve this answer | |

Add this method into following class

public function addFieldToFilter($field, $condition = null)
    if ($field === 'order_id') {
        // custom condition

    return parent::addFieldToFilter($field, $condition);
| improve this answer | |
  • best way is addFilterToMap – Pradeep Kumar Nov 27 '15 at 3:44

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.