CListView searching and filtering like CGridView

Does anyone has any experience with implementing searching/filtering to CListView? Is there an easy way to do it, by for example reusing build-in support (just like it is done in CGridView) or if such solution would have to be written from scratch? Or maybe a better support it would to be rather extend CGridView with build-in supportfor searching only to change it the way, it would support externals views per each row (the only thing from CListView I need right now)

Also, a bit off-topic but still related. Yii is providing (own?) jQuery functions for updating CGridView, CListView etc. like for example $.fn.yiiGridView.update. Is there any guide page for describing these jQuery addition or the only way to work with them is to analyse Yii core code?

Has any got any idea about this problem?

I don’t like reminding myself, but this is rather hot problem for me right now and even I thought it will be ease (or at least should be - as both classes are descent of the same parent class), it seems that after twelve hours of thinking over it I come up with nothing! :[

Haven’t done this (yet)… but an idea would be to check the CGridView code and how the filter is implemented… and then to make a similar implementation in CListView… not an easy task…

and there is the jQuery component to the filter in jquery.yiigridview.js

Haven’t thought about this idea. Seems interesting. Have you or anyone else heard about extension similar to this? I’ll be needing this solution soon or later so I need to code it myself, and I don’t want to reinvent already invented wheel again.

What do you think about exactly opposite solution - i.e. take CGridView code and modify it so it does not renders rows itself and instead partially renders provided view file, just like CListView do? What would be faster or easier to achieve, in your opinion?

IMO it’s easier to make a filter for CListView… you can make it much simpler - like the advanced search form for the default admin view… but you need to write some complex jQuery for this to work… like it’s done for the grdiview…

Changind CGridView is easy… you just change the renderTableRow to call a partialrender… but in that case you would loose the filters as you would not have the columns anymore…

I thought that renderTableRow() only renders table body rows, leaving header and footer intact.I thought that filters are part of header. Loosing filters is not an opiton, therefore I’ll have to follow your suggestion and take approach of introducing filters to CListView. Thanks.

It does render only the table rows… the header and the filter under the header would be rendered… but how would you render the data in your renderTableRow()?

Don’t blame me! :) I’m just guessing to find the best solution… :)

Eee… render footer and header (along with filters) normally - i.e. leave it to a base class (CGridView) from which new class would extend - and only change renderTableRow() to partially render provided view? To much mixing? :)

:) As I poinded a day ago to Mike… a forum chat would come handy sometime…

I’m just wondering how would that look and if it would be intuitive for using… as the filter would be rendered in columns… but as I understand you the table rows would not be rendered in columns… but it’s worth a try…

No, table rows would have to be rendered in columns and in exactly the same number of columns as header with filters (though it would be a developer task, inside partial view) because you can’t insert anything except trs and tds into table. It is violation of standards and such table (or whole page) would probably gone hell in final view.

I’m only thinking about solution that would allow developer to reuse all the power of CGridView while giving him more flexibility in rendering grid rows’ contents. This way I could be able to do, what I’m intend to do - i.e. be able to render two or more rows per one record (model instance). Yes, I know - I’m a selfish bastard, thinking only about my problems, not the other ones! :]

Check out what I did here. Its pretty simple once you wrap your mind around it. I dont know if I have the best solution but its very easy to implement and reuses what you already have created for you from gii.

Thanks a lot! Seems interesting. The problem is, that you answered a question I asked over nine months ago! :] I not only solved that problem (and of course - already forgot, how? :]), but I’m also not working any more on a project I need that solution for! :] But, thanks anyway! :]