I'm starting in YII 1 and I'm trying to use grid search in my YII application but my The grid search is not working. Please help me. Thanks in advance.
viewSurveyList.php
& lt ;? Php $ this- & gt; Page title = Yii :: app () - & gt; Name '- survey data'; ? & Gt; & Lt; Div id = "inner content" style = "padding-top: 30px;" & Gt; & Lt; H1 & gt; & Lt ;? Php echo SURVEYLISTHEADTITLE; ? & Gt; & Lt; / H1> & Lt; Div class = "row-button-right" & gt; & Lt ;? Php echo CHtml :: Button ('New survey', array ('type' = & gt; submit ',' submit '=> array (' site / create server ')) ;; & Gt; & Lt; / Div & gt; & Lt ;? Php $ this- & gt; Widgets ('zii.widgets.grid.CgrridView', array ('id' = & gt; 'service-list', 'data provider' => $ model survey- & gt; search (), 'filter' = & $ 'Model survey,' pager '= & gt; array (' header '=> gt;' ',' prevPageLabel '= & gt;' previous ',' next page label '= & gt;' next ',' Maximum button '= & gt; SHOWNUMBEROFPAGENUMBER),' pager class' = & gt; 'endorsement', 'empty text' = & gt; 'no survey found', 'template' = & gt; "{item} \ n {Summary} \ n {pager} ", 'column' = & gt; array (array ('header' = & gt; 'name', 'name' = & gt; 'name', 'value' = & gt; '$ Data- & gt; No ',' HeaderHtmlOptions '= & gt; array (' width '= & gt; '80%', 'valign' = & gt; medium ',' alignment '= & gt;' center '),' htmlovptions '=' & Gt; array ('width' = & gt; '80% ',' valign '= & gt;' top ',' align '= & gt;' left '),' filter '= & gt; CHtml: : ActiveTextField ($ Model: survey, 'name', array ('placeholder' = & gt; 'name of survey')),), array ('header' = & gt; 'action', 'name' = & gt; 'Action', 'value' = & gt; function ($ data) {echo survey :: model () - & gt; GetActionLink ($ data); }, 'HeaderHtmlOptions' = & gt; Array ('width' = & gt; '20% ',' valign '= & gt; medium', 'align' => = 'center'), 'html_Options' = & gt; Array 'width' = & gt; '20% ',' valign '= & gt; Top ',' align '=> Left '),' filter '= & gt; CHtml :: link ('filter filter', array 'site / survey list'), array ('title' = & gt; 'filter filter')),),),)); ? & Gt; & Lt; / Div & gt;
Model survey. Php
Public function search () {// @todo Please modify the following code to remove those features that should not be searched. Print_r (this $); $ Criteria = new cdccitrea; $ Benchmarking & gt; Comparison ('id', $ this-> ID); $ Benchmarking & gt; Comparison ('name', $ this-> name, true); // $ Benchmarking & gt; Comparison ($ this-> isDeleted ', isDeleted); $ Benchmarking & gt; Comparison ('Created On', $ this- & gt; CreatedOn, True); $ Benchmarking & gt; Comparison ('LastModifiedOn', $ this-> LastModifiedOn, true); Return the new Cakvidet Provider ($ this, array ('criteria' = & gt; $ criterion, 'endorsement' = & gt; array ('page size' => SETTINGPAGESIZE), // number of settings rows per page); } Public Function Rules () {// The following rule is used by search () Returns array (array ('id, name, created, last modifiedone, questionnaam,' 'safe', 'on' = & gt; '),};}
action call from SiteController.php
public function action SurveyList () {$ ModelSurvey = new survey ('search'); $ this- & gt; render ('viewSurveyList', array ('modelSurvey' => $ modelSurvey));}
Enter the code below into your action SurveyList method
public actions SurveyList () {$ modelSurvey = new Survey ('search'); if (isset ($ _GET ['survey']) $ model survey-> attribute = $ _ ['survey']; $ this- & gt; render ('viewSurveyList ', Array (' modelSurvey '= & gt; $ ModelSurvey)); }
No comments:
Post a Comment