I have a post model, it is having attributes like section,category. in Gii generated code of admin controller, by default all the posts are loaded via Cactivedataprovider . But what i want is, to provide links/drop-down menu for the users to select a particular section or category, and then show the Posts having this particular section or category. so the value for the section/category will be taken from $_GET[]. How can i add this to tell Cactivedataprovider to load the posts of a particular category or section only?
Regards
Page 1 of 1
Adding A Pre-Condition To Data Loaded In Cgridview
#2
Posted 04 February 2013 - 02:20 AM
Do as
1 - Create a dropdown with onChange reload the page with selected value(using javascript)
2 - In controller's action where you are calling for data i.e. CActiveRecord, use CDBCriteria to set the category for whom you want to list the articles
thanks
1 - Create a dropdown with onChange reload the page with selected value(using javascript)
2 - In controller's action where you are calling for data i.e. CActiveRecord, use CDBCriteria to set the category for whom you want to list the articles
thanks
#3
Posted 04 February 2013 - 02:47 AM
PeRoChAk, on 04 February 2013 - 02:20 AM, said:
Do as
1 - Create a dropdown with onChange reload the page with selected value(using javascript)
2 - In controller's action where you are calling for data i.e. CActiveRecord, use CDBCriteria to set the category for whom you want to list the articles
thanks
1 - Create a dropdown with onChange reload the page with selected value(using javascript)
2 - In controller's action where you are calling for data i.e. CActiveRecord, use CDBCriteria to set the category for whom you want to list the articles
thanks
I am using Gii generated search() method, which in turn use CDbcriteria->compare() method for searching. since the paging and filtering is done using AJAX, so i am confuse how exactly to add a condition to existing $CDbcriteria->compare() statements?
#4
Posted 04 February 2013 - 04:43 AM
Hi Sukhwinder,
Make use of the "advanced search form" in the gii generated admin page. The form should have the text field for category_id ... you can replace it with a dropdown list ... and the job is done. Your search() method should already have the code to handle searching by category_id.
Please read the following wiki for detailed explanation.
http://www.yiiframew...ivedataprovider
Make use of the "advanced search form" in the gii generated admin page. The form should have the text field for category_id ... you can replace it with a dropdown list ... and the job is done. Your search() method should already have the code to handle searching by category_id.
Please read the following wiki for detailed explanation.
http://www.yiiframew...ivedataprovider
Share this topic:
Page 1 of 1

Help












