How can I use my own forms for CGridView Ajax filtering ?

Hi all!

As you know, by default CGridView uses it’s own filters (inputs from <tr> with css class ‘.filters’).

But what if I want to create my own form instead of this ugly filters? I want to have opportunity to place this form whenever I want on the page, and do ajax filtering using it, like if it is standart CGridView filters. But logic of ajax filtering located somewhere deep in the code of yiigridview.js, as I can see.

Am I mistaken? And if I am, tell me please, how can I do this?

Of course, I can write javascript code to ajax filtering and updating grid without using opportunities, provided by framework, but I want to know if there is ‘legal’ and not ugly approach for this in CGridView.

Hi Layne,

gii-generated admin page already has an "Advanced Search" form that is capable of the things you want.

What you have to do is just the following.

  1. remove some code that is toggling the search form display, and show it always

  2. modify the search form to suit your needs and taste

Damn it :) I started my last Yii-project long time ago, and forgot such a simple thing :)

Thank you very much!