Skip to content

Deprecated since 7.2

This page documents the classic module layer (CBController and cbInit()). It still works in every 7.x release, but new code should use resources and pages.

Use instead: modifyQuery() on the resource, or Table::modifyQueryUsing().

How To Put A Custom Condition At Grid Data ​

In some case you need to make a condition of grid data query.

CRUDBooster provide the method that you can use to customize the query of grid data.

php
public function hook_query_index(&$query) {
  //Your any custom query
}

This special method come in each controller that you've genereated. If you don't find it, you may create it one.

For example, you have a table products:

Field NameData Type
idint(PK)
craeted_attimestamp
namevarchar(255)
descriptiontext
is_activeint(1)

Now, you want to show the data where is_active is 1

Your hook_query_index should be :

php
public function hook_query_index(&$query) {
  $query->where('is_active',1);
}

What's Next ​

Table Of Contents ​

Released under the MIT License.