Magento – Magento 2 – Customize Customer Grid Collection Data

admincollection;customer-gridmagento2

I want to add a where clause in customer grid collection.
e.g.

$currentCollection->getSelect()->where('custom condition');

I tried to google it but got no success.
I have also tried to implement customization methods used for product and order grid but it seems that di.xml and ui component xml files are different.

e.g when I try to add code

<argument name="addFieldStrategies" xsi:type="array">
        <item name="title" xsi:type="object">Namespace\Module\Ui\DataProvider\Test\AddTitleFieldToCollection</item>
</argument>

in file /app/code/Namespace/Module/view/adminhtml/ui_component/customer_listing.xml

I get

Element 'arguments': This element is not expected. Expected is ( argument ).

I have also tried modifying collection through observer but it seems event customer_grid_collection_load_before does not exist.

I don't want to modify core code and I have no clue from where to start. Please comment if any other information needed.

Best Answer

EDIT I was wrong - in Magento 2 grid is built other way, look at this: http://webkul.com/blog/create-grid-edit-add-grid-row-and-installer-in-magento2/

And here you can find way to add custom filter for grid collection To add default filter to grid in Magento2?