{"id":77,"date":"2014-09-02T13:33:08","date_gmt":"2014-09-02T08:33:08","guid":{"rendered":"http:\/\/developer.uz\/blog\/?p=77"},"modified":"2014-09-03T13:38:40","modified_gmt":"2014-09-03T08:38:40","slug":"yii-cgridview-part2","status":"publish","type":"post","link":"https:\/\/developer.uz\/blog\/yii-cgridview-part2\/","title":{"rendered":"\u041e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u0445 Yii CGridView \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445. \u0427\u0430\u0441\u0442\u044c 2: \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a \u0434\u0430\u043d\u043d\u044b\u0445"},"content":{"rendered":"<p>\u0412 <a title=\"\u041e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u0445 Yii CGridView \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445. \u0427\u0430\u0441\u0442\u044c 1: \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435\" href=\"http:\/\/developer.uz\/blog\/yii-cgridview-part1\/\">\u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438<\/a>, \u043c\u044b \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043e\u0444\u043e\u0440\u043c\u043b\u0435\u043d\u0438\u044f \u0432\u0438\u0434\u0436\u0435\u0442\u0430 CGridView, \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0438 \u043a\u0430\u043a \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0438\u043b\u0438 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 \u043a\u043d\u043e\u043f\u043a\u0438, \u0432\u044b\u0432\u043e\u0434 \u043f\u0435\u0439\u0434\u0436\u0438\u043d\u0430\u0446\u0438\u0438, \u0444\u043e\u0440\u043c\u0430\u0442 \u0432\u044b\u0432\u043e\u0434\u0438\u043c\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u0445 <strong>\u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f CGridView<\/strong>.<br \/>\n\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0432\u043d\u043e\u0432\u044c \u0432\u0437\u0433\u043b\u044f\u043d\u0435\u043c \u043d\u0430 \u0442\u0438\u043f\u043e\u0432\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f CGridView:<\/p>\n<pre class=\"brush: php; title: \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434; notranslate\" title=\"\u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434\">\r\n&lt;?php $this-&gt;widget('zii.widgets.grid.CGridView', array(\r\n    'id'=&gt;'country-grid',\r\n    'dataProvider'=&gt;$model-&gt;search(),\r\n    'filter'=&gt;$model,\r\n    'columns'=&gt;array(\r\n        'id',\r\n        'name',\r\n        'region',\r\n        array(\r\n            'class'=&gt;'CButtonColumn',\r\n        ),\r\n    ),\r\n)); ?&gt;\r\n<\/pre>\n<p>\u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u0431\u0443\u0434\u0443\u0449\u0435\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u0432 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0435 dataProvider \u0432 \u0432\u0438\u0434\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 CActiveDataProvider. \u0412 \u043c\u043e\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u0442\u0440\u0430\u043d \u0438 $model \u0432 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0438 &#8212; \u044d\u0442\u043e \u043e\u0431\u044a\u0435\u043a\u0442 \u043a\u043b\u0430\u0441\u0441\u0430 Country. \u0414\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 \u043a\u043b\u0430\u0441\u0441\u0430 Country \u0441 \u0438\u043c\u0435\u043d\u0435\u043c search. <\/p>\n<pre class=\"brush: php; title: \u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u043c\u0435\u0442\u043e\u0434\u0430 search; notranslate\" title=\"\u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u043c\u0435\u0442\u043e\u0434\u0430 search\">\r\npublic function search()\r\n{\r\n  $criteria=new CDbCriteria;\r\n\r\n  $criteria-&gt;compare('name',$this-&gt;name,true);\r\n  $criteria-&gt;compare('region',$this-&gt;region,true);\r\n\r\n  return new CActiveDataProvider($this, array(\r\n     'criteria'=&gt;$criteria,\r\n  ));\r\n}\r\n<\/pre>\n<p>\u041c\u0435\u0442\u043e\u0434 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 CActiveDataProvider, \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044f \u043a \u043d\u0435\u043c\u0443 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0432\u044b\u0431\u043e\u0440\u043a\u0438 $criteria. <\/p>\n<h2>\u041a\u0430\u043a \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0432 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f CGridView<\/h2>\n<p>\u0427\u0442\u043e\u0431\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f CGridView \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u0430\u043a:<\/p>\n<pre class=\"brush: php; title: \u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u043c\u0435\u0442\u043e\u0434\u0430 search; notranslate\" title=\"\u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u043c\u0435\u0442\u043e\u0434\u0430 search\">\r\npublic function search()\r\n{\r\n  $criteria=new CDbCriteria;\r\n\r\n  $criteria-&gt;compare('name',$this-&gt;name,true);\r\n  $criteria-&gt;compare('region',$this-&gt;region,true);\r\n\r\n  $criteria-&gt;addCondition('moderation=0');\r\n\r\n  return new CActiveDataProvider($this, array(\r\n     'criteria'=&gt;$criteria,\r\n  ));\r\n}\r\n<\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 CGridView \u0431\u0443\u0434\u0443\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u043f\u0438\u0441\u0438 \u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u043e\u043b\u0435 moderation \u0440\u0430\u0432\u043d\u043e 0. \u0412\u0430\u0440\u044c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u044f \u0432 \u043c\u0435\u0442\u043e\u0434 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u0430\u043a:<\/p>\n<pre class=\"brush: php; title: \u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u043c\u0435\u0442\u043e\u0434\u0430 search; notranslate\" title=\"\u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u043c\u0435\u0442\u043e\u0434\u0430 search\">\r\npublic function search($moderation='')\r\n{\r\n  $criteria=new CDbCriteria;\r\n\r\n  $criteria-&gt;compare('name',$this-&gt;name,true);\r\n  $criteria-&gt;compare('region',$this-&gt;region,true);\r\n\r\n  if(is_numeric($moderation))\r\n    $criteria-&gt;addCondition('moderation='.$moderation);\r\n\r\n  return new CActiveDataProvider($this, array(\r\n     'criteria'=&gt;$criteria,\r\n  ));\r\n}\r\n<\/pre>\n<pre class=\"brush: php; title: \u0422\u0435\u043f\u0435\u0440\u044c \u0432\u043c\u0435\u0441\u0442\u043e; notranslate\" title=\"\u0422\u0435\u043f\u0435\u0440\u044c \u0432\u043c\u0435\u0441\u0442\u043e\">'dataProvider'=&gt;$model-&gt;search(),<\/pre>\n<pre class=\"brush: php; title: \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0437\u0432\u0430\u0442\u044c; notranslate\" title=\"\u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0437\u0432\u0430\u0442\u044c\">'dataProvider'=&gt;$model-&gt;search(1),<\/pre>\n<p> \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u043c\u043e\u0434\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 <\/p>\n<pre class=\"brush: php; title: \u043b\u0438\u0431\u043e; notranslate\" title=\"\u043b\u0438\u0431\u043e\">'dataProvider'=&gt;$model-&gt;search(0),<\/pre>\n<p> \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0435 \u043f\u0440\u043e\u043c\u043e\u0434\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. <\/p>\n<h2>\u041a\u0430\u043a \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0447\u0438\u0441\u043b\u043e \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u0432 CGridView<\/h2>\n<p>\u041e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e. \u041d\u0443\u0436\u043d\u043e \u044f\u0432\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c pageSize \u0432 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 CActiveDataProvider<\/p>\n<pre class=\"brush: php; title: \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434; notranslate\" title=\"\u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434\">\r\n return new CActiveDataProvider($this, array(\r\n     'criteria'=&gt;$criteria,\r\n     'pagination' =&gt; array('pageSize' =&gt; 20)\r\n  ));\r\n<\/pre>\n<h2>\u041a\u0430\u043a \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 CGridView<\/h2>\n<p>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u0439 \u0432 Yii &#8212; \u044d\u0442\u043e \u0442\u0435\u043c\u0430 \u0434\u043b\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438. \u041d\u043e \u0442\u0430\u043a \u043a\u0430\u043a \u0432 \u043f\u0440\u043e\u0448\u043b\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c \u043e \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c\u0441\u044f \u043d\u0430 \u044d\u0442\u043e\u043c \u043c\u043e\u043c\u0435\u043d\u0442\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435.<br \/>\n\u0414\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043d\u0443\u0436\u043d\u043e \u0432\u043e-\u043f\u0435\u0440\u0432\u044b\u0445 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u044d\u0442\u0443 \u0441\u0432\u044f\u0437\u044c \u0432 \u043c\u043e\u0434\u0435\u043b\u0435 \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 relations:<\/p>\n<pre class=\"brush: php; title: \u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u0432\u044f\u0437\u0438 \u0432 \u043c\u043e\u0434\u0435\u043b\u044c Country; notranslate\" title=\"\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u0432\u044f\u0437\u0438 \u0432 \u043c\u043e\u0434\u0435\u043b\u044c Country\">\r\npublic function relations()\r\n{\r\n    return array(\r\n       'region' =&gt; array(self::HAS_ONE, 'Region', array('id' =&gt; 'region')),\r\n    );\r\n}\r\n<\/pre>\n<p>\u041e\u043f\u0438\u0441\u0430\u043d\u043d\u0430\u044f \u0441\u0432\u044f\u0437\u044c \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0447\u0442\u043e \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 Country \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043e\u0434\u043d\u0430 \u0437\u0430\u043f\u0438\u0441\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u044b Region. \u041f\u043e\u043b\u0435 id \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 Region \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0440\u0430\u0432\u043d\u043e \u043f\u043e\u043b\u044e region \u0442\u0430\u0431\u043b\u0438\u0446\u044b Country. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e \u0441\u0432\u044f\u0437\u044f\u0445 ActiveRecord \u0432 Yii \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u044e\u0441\u044c \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e, \u0442\u043a \u044d\u0442\u043e \u0442\u043e\u0436\u0435 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043e\u0431\u0448\u0438\u0440\u043d\u0430\u044f \u0442\u0435\u043c\u0430, \u0447\u0442\u043e\u0431\u044b \u0440\u0430\u0441\u043a\u0440\u044b\u0432\u0430\u0442\u044c \u0435\u0435 \u0442\u0443\u0442.<br \/>\n\u0422\u0435\u043f\u0435\u0440\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u044d\u0442\u0443 \u0441\u0432\u044f\u0437\u044c \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430 \u0434\u044b\u043d\u043d\u044b\u0445:<\/p>\n<pre class=\"brush: php; title: \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u0439 \u0432 \u043c\u0435\u0442\u043e\u0434 search; notranslate\" title=\"\u0414\u043e\u0431\u0430\u0432\u0438\u043c \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u0439 \u0432 \u043c\u0435\u0442\u043e\u0434 search\">\r\n$criteria-&gt;with = array('region');\r\n<\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0438 \u0432\u044b\u0432\u043e\u0434\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 CGridView \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043a \u043f\u043e\u043b\u044f\u043c \u043c\u043e\u0434\u0435\u043b\u0438 Region, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u0430\u043a $data->region->title<br \/>\n\u0415\u0441\u043b\u0438 \u043f\u043e \u043a\u0430\u043a\u0438\u043c \u043b\u0438\u0431\u043e \u043f\u0440\u0438\u0447\u0438\u043d\u0430\u043c \u0432\u0430\u043c \u043d\u0435 \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 search, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043b\u044e\u0431\u043e\u0439 \u0434\u0440\u0443\u0433\u043e\u0439 \u043c\u0435\u0442\u043e\u0434, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0438\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 CActiveDataProvider. <\/p>\n<h2>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0444\u0438\u043b\u044c\u0442\u0440\u0430 \u0434\u043b\u044f CGridView<\/h2>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u0430\u043a \u044d\u0442\u043e\u0442 \u0444\u0438\u043b\u044c\u0442\u0440 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. <\/p>\n<ul>\n<li><strong>\u0428\u0430\u0433 1: \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0444\u0438\u043b\u044c\u0442\u0440\u0430 \u0432 CGridView<\/strong><br \/>\n\u0412 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u0435\u0441\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0437\u0430\u0434\u0430\u0442\u044c \u0444\u0438\u043b\u044c\u0442\u0440 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u043e\u043b\u044f<\/p>\n<pre class=\"brush: php; title: \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043f\u043e\u043b\u044f \u0432 \u0432\u044b\u0437\u043e\u0432\u0435 \u0432\u0438\u0434\u0436\u0435\u0442\u0430 CGridView; notranslate\" title=\"\u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043f\u043e\u043b\u044f \u0432 \u0432\u044b\u0437\u043e\u0432\u0435 \u0432\u0438\u0434\u0436\u0435\u0442\u0430 CGridView\">\r\narray(\r\n  'name'   =&gt; 'region',\r\n  'filter' =&gt; Region::getAll(),\r\n  'value'  =&gt; 'Region::getNameByID($data-&gt;region)',\r\n),\r\n<\/pre>\n<p>\u0418\u043b\u0438 \u043e\u0442\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0435\u0433\u043e, \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0432 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 filter \u0432 false. \u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0444\u0438\u043b\u044c\u0442\u0440 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u043c \u043f\u043e\u043b\u0435\u043c. \u0412 \u043c\u043e\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435, \u043c\u0435\u0442\u043e\u0434 Region::getAll() \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043c\u0430\u0441\u0441\u0438\u0432 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 \u043a\u043b\u044e\u0447=>\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435. \u0424\u0438\u043b\u044c\u0442\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0435\u0433\u043e \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u0432\u044b\u043f\u0430\u0434\u0430\u044e\u0449\u0435\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430. \u041f\u0440\u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0444\u0438\u043b\u044c\u0442\u0440\u0430, \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 AJAX-\u0437\u0430\u043f\u0440\u043e\u0441, \u0432\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432 \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442\u0441\u044f \u0432 \u0432\u0438\u0434\u0435 GET \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0432 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 action \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430.\n<\/li>\n<li><strong>\u0428\u0430\u0433 2: \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430<\/strong>\n<pre class=\"brush: php; title: \u0412 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0435 \u0432\u044b \u043d\u0430\u0439\u0434\u0435\u0442\u0435 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0439 \u043a\u043e\u0434; notranslate\" title=\"\u0412 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0435 \u0432\u044b \u043d\u0430\u0439\u0434\u0435\u0442\u0435 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0439 \u043a\u043e\u0434\">\r\n   $model=new Country('search');\r\n   $model-&gt;unsetAttributes(); \r\n   if(isset($_GET['Country']))\r\n       $model-&gt;attributes=$_GET['Country'];\r\n\r\n   $this-&gt;render('admin',array(\r\n         'model'=&gt;$model,\r\n   ));\r\n<\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 GET \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b, \u0442\u043e \u043e\u043d\u0438 \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0432 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430. \u0414\u043b\u044f \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u0438\u0441 \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, <strong>\u043f\u0440\u0438\u0441\u0432\u043e\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435\u043c \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432 \u043c\u043e\u0434\u0435\u043b\u0438 \u0443\u043a\u0430\u0437\u0430\u043d\u044b \u043a\u0430\u043a \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u0435<\/strong>.<\/p>\n<pre class=\"brush: php; title: \u041f\u0440\u0438\u043c\u0435\u0440 \u043f\u0440\u0430\u0432\u0438\u043b \u0432 \u043c\u043e\u0434\u0435\u043b\u0438 Country; notranslate\" title=\"\u041f\u0440\u0438\u043c\u0435\u0440 \u043f\u0440\u0430\u0432\u0438\u043b \u0432 \u043c\u043e\u0434\u0435\u043b\u0438 Country\">\r\npublic function rules()\r\n{\r\n\treturn array(\r\n\t\tarray('name, region', 'required'),\r\n\t\tarray('name, region', 'safe'),\r\n\t\t);\r\n\t}\r\n<\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0444\u0438\u043b\u044c\u0442\u0440 CGridView \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u0432 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u044c\u0442\u0435, \u0443\u043a\u0430\u0437\u0430\u043d \u043b\u0438 \u0430\u0442\u0440\u0438\u0431\u0443\u0442, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0432\u044b \u043f\u044b\u0442\u0430\u0435\u0442\u0435\u0441\u044c \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432\u0430\u0442\u044c, \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0433\u043e \u0432 \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u0445 \u0434\u0430\u043d\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438.\n<\/li>\n<li><strong>\u0428\u0430\u0433 2: \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0443\u0441\u043b\u043e\u0432\u0438\u0439 \u0444\u0438\u043b\u044c\u0442\u0440\u0430<\/strong>\n<pre class=\"brush: php; title: \u0412\u0437\u0433\u043b\u044f\u043d\u0438\u0442\u0435 \u043d\u0430 \u044d\u0442\u0438 \u0441\u0442\u0440\u043e\u043a\u0438 \u043c\u0435\u0442\u043e\u0434\u0430 search; notranslate\" title=\"\u0412\u0437\u0433\u043b\u044f\u043d\u0438\u0442\u0435 \u043d\u0430 \u044d\u0442\u0438 \u0441\u0442\u0440\u043e\u043a\u0438 \u043c\u0435\u0442\u043e\u0434\u0430 search\">\r\n $criteria-&gt;compare('name',$this-&gt;name,true);\r\n $criteria-&gt;compare('region',$this-&gt;region,true);\r\n<\/pre>\n<p>\u0422\u0443\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0443\u0441\u043b\u043e\u0432\u0438\u044f, \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u044e\u0449\u0438\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0441 \u043f\u043e\u043b\u044f\u043c\u0438. \u0414\u0430\u043d\u043d\u044b\u0435 \u0444\u0438\u043b\u044c\u0442\u0440\u0430 \u0431\u044b\u043b\u0438 \u043f\u0440\u0438\u0441\u0432\u043e\u0435\u043d\u044b \u043a \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u043c \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043d\u0430 \u043f\u0440\u043e\u0448\u043b\u043e\u043c \u0448\u0430\u0433\u0435. \u0422\u0440\u0435\u0442\u0438\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0441 \u043f\u043e\u0434\u0441\u0442\u0440\u043e\u043a\u043e\u0439. \u0422\u0435 \u0432\u043c\u0435\u0441\u0442\u043e name=$this->name \u0432 \u0441\u043b\u0443\u0447\u0430\u0438 \u043a\u043e\u0433\u0434\u0430 \u0442\u0440\u0435\u0442\u0438\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u0432 false \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d \u043f\u043e\u0438\u0441\u043a \u043f\u043e \u0443\u0441\u043b\u043e\u0432\u0438\u044e name like %$this->name%.\n<\/li>\n<\/ul>\n<h2>\u041a\u043d\u043e\u043f\u043a\u0430 \u0441\u0431\u0440\u043e\u0441\u0438\u0442\u044c \u0444\u0438\u043b\u044c\u0442\u0440 \u0434\u043b\u044f CGridView<\/h2>\n<p>\u0414\u043b\u044f \u0441\u0431\u0440\u043e\u0441\u0430 \u0444\u0438\u043b\u044c\u0442\u0440\u0430 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043e\u0447\u0438\u0441\u0442\u0438\u0442\u044c \u0432\u0441\u0435 \u043f\u043e\u043b\u044f. \u041d\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u043f\u0440\u0438\u0432\u044b\u043a\u043b\u0438 \u043a \u043a\u043d\u043e\u043f\u043a\u0435 &#171;\u041e\u0447\u0438\u0441\u0442\u0438\u0442\u044c \u0444\u0438\u043b\u044c\u0442\u0440&#187;. \u0415\u0435 \u043c\u044b \u0441\u0435\u0439\u0447\u0430\u0441 \u0438 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c.<br \/>\n\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u043a\u043b\u0430\u0441\u0441, \u043d\u0430\u0437\u043e\u0432\u0435\u043c \u0435\u0433\u043e ButtonWithResetButtonColumn, \u043e\u0442\u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043e\u0442 CButtonColumn. \u041f\u043e\u043c\u0435\u0441\u0442\u0438\u043c \u0444\u0430\u0438\u043b \u044d\u0442\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0432 protected\/components<\/p>\n<pre class=\"brush: php; title: \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434; notranslate\" title=\"\u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434\">\r\nclass ButtonWithResetButtonColumn extends CButtonColumn {\r\n    public function renderFilterCellContent() {\r\n        $js = &quot;\r\n            jQuery(document).on('click', '#{$this-&gt;grid-&gt;id} .reset', function() {\r\n                var $ = jQuery,\r\n                    id = $(this).data('grid-id'),\r\n                    inputSelector = '#' + id + ' .filters input, ' + '#' + id + ' .filters select';\r\n\r\n                $(inputSelector).each(function(index, elem) {\r\n                    $(elem).val('');\r\n                });\r\n                var data = $.param($(inputSelector));\r\n                $.fn.yiiGridView.update(id, {data: data});\r\n               return false;\r\n            });\r\n        &quot;;\r\n        Yii::app()-&gt;getClientScript()-&gt;registerScript(__CLASS__ . '#' . $this-&gt;id, $js);\r\n        echo &quot;&lt;input class='reset' data-grid-id='{$this-&gt;grid-&gt;id}' type='button' value='Reset'&gt;&quot;;\r\n    }\r\n}\r\n<\/pre>\n<p>\u041a\u043b\u0430\u0441\u0441 \u0434\u043e\u0440\u0438\u0441\u043e\u0432\u044b\u0432\u0430\u0435\u0442 \u043a\u043d\u043e\u043f\u043a\u0443 \u0441 \u043d\u0430\u0434\u043f\u0438\u0441\u044c\u044e Reset \u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 JS \u0441\u043e\u0431\u044b\u0442\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043e\u0447\u0438\u0449\u0430\u0435\u0442 \u0432\u0441\u0435 \u043f\u043e\u043b\u044f \u0444\u0438\u043b\u044c\u0442\u0440\u0430 \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 ajax \u043e\u0431\u043d\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0433\u0440\u0438\u0434\u0430.<br \/>\n\u0422\u0435\u043f\u0435\u0440\u044c \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0448 \u043d\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0432\u043c\u0435\u0441\u0442\u043e CButtonColumn \u0432 \u0432\u044b\u0437\u043e\u0432\u0435 \u0432\u0438\u0434\u0436\u0435\u0442\u0430:<\/p>\n<pre class=\"brush: php; title: \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434; notranslate\" title=\"\u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434\">\r\n&lt;?php $this-&gt;widget('zii.widgets.grid.CGridView', array(\r\n    'id'=&gt;'country-grid',\r\n    'dataProvider'=&gt;$model-&gt;search(),\r\n    'filter'=&gt;$model,\r\n    'columns'=&gt;array(\r\n        'id',\r\n        'name',\r\n        'region',\r\n        array(\r\n            'class'=&gt;'ButtonWithResetButtonColumn',\r\n        ),\r\n    ),\r\n)); ?&gt;\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u0412 \u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438, \u043c\u044b \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043e\u0444\u043e\u0440\u043c\u043b\u0435\u043d\u0438\u044f \u0432\u0438\u0434\u0436\u0435\u0442\u0430 CGridView, \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0438 \u043a\u0430\u043a \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0438\u043b\u0438 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 \u043a\u043d\u043e\u043f\u043a\u0438, \u0432\u044b\u0432\u043e\u0434 \u043f\u0435\u0439\u0434\u0436\u0438\u043d\u0430\u0446\u0438\u0438, \u0444\u043e\u0440\u043c\u0430\u0442 \u0432\u044b\u0432\u043e\u0434\u0438\u043c\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u0445 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f CGridView. \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0432\u043d\u043e\u0432\u044c \u0432\u0437\u0433\u043b\u044f\u043d\u0435\u043c \u043d\u0430 \u0442\u0438\u043f\u043e\u0432\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f CGridView: \u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u0431\u0443\u0434\u0443\u0449\u0435\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u0432 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0435 dataProvider \u0432 \u0432\u0438\u0434\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 CActiveDataProvider. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[9],"tags":[12],"_links":{"self":[{"href":"https:\/\/developer.uz\/blog\/wp-json\/wp\/v2\/posts\/77"}],"collection":[{"href":"https:\/\/developer.uz\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/developer.uz\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/developer.uz\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/developer.uz\/blog\/wp-json\/wp\/v2\/comments?post=77"}],"version-history":[{"count":7,"href":"https:\/\/developer.uz\/blog\/wp-json\/wp\/v2\/posts\/77\/revisions"}],"predecessor-version":[{"id":95,"href":"https:\/\/developer.uz\/blog\/wp-json\/wp\/v2\/posts\/77\/revisions\/95"}],"wp:attachment":[{"href":"https:\/\/developer.uz\/blog\/wp-json\/wp\/v2\/media?parent=77"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/developer.uz\/blog\/wp-json\/wp\/v2\/categories?post=77"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/developer.uz\/blog\/wp-json\/wp\/v2\/tags?post=77"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}