Magento – Filter search not working for custom admin grid

gridmagento2.2PHPsearch

I have created a custom admin grid. In that search is not working properly. Anyone knows please provide me a solution enter image description here

ox_homeslider_post_listiong.xml

<filterSearch name="fulltext">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="provider" xsi:type="string">ox_homeslider_post_listing.ox_homeslider_post_listing_data_source</item>
                    <item name="chipsProvider" xsi:type="string">ox_homeslider_post_listing.ox_homeslider_post_listing.listing_top.listing_filters_chips</item>
                    <item name="storageConfig" xsi:type="array">
                        <item name="provider" xsi:type="string">ox_homeslider_post_listing.ox_homeslider_post_listing.listing_top.bookmarks</item>
                        <item name="namespace" xsi:type="string">current.search</item>
                    </item>
                </item>
            </argument>
        </filterSearch>

Best Answer

Missing index in your table can cause this effect. Try adding index to your table ie in upgrade script like:

public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $context)
{
    $setup->startSetup();

    if (version_compare($context->getVersion(), '1.0.1') == -1) {

        $table = $setup->getTable('table_name');

        $setup->getConnection()
            ->addIndex(
                $table,
                $setup->getIdxName(
                    $table,
                    ['first_name', 'last_name', 'company_name', 'vendor_details', 'other_fields_in_your_table'],
                    \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_FULLTEXT
                ),
                ['first_name', 'last_name', 'company_name', 'vendor_details', , 'other_fields_in_your_table'],
                \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_FULLTEXT
            )
        ;
    }

    $setup->endSetup();
}

then bin/magento setup:upgrade bin/magento c:c

Related Topic