Filter Partial Match With Integer Type

Hi! Is it possible to filter a column in a gridview with type integer with partial match?

This will only work for a column in your table that is of a string datatype.

Your solution can be changing that column to CHAR or VARCHAR. In the model you change the compare-line for the field in the function called search (you’ll see many lines like these):

$criteria->compare('number',$this->number,true); // must be char, varchar and not numerical in database

Note that you need to make sure that the user only inserts integers if you change the field to a string datatype.

Read the documentation for the compare function:


You can cast that column to string in the condition:

CAST(integer_column AS VARCHAR(10)) LIKE '1123%'

Searching in such way will be slower. In PostgreSQL you could create an index using such expression, but in MySQL it’s not possible. So you would have to create another column and keep converted values there or just convert this column.