Cgridview

Yii CGridView hyperlink open in new tab

假如想象 提交于 2020-01-24 17:07:05
问题 I have made one column of my yii CGridview as a hyperlink. But on clicking it, it opens link address within the same tab. How can I open the link address in a new tab ? array( 'header'=>'Name', 'name' => 'name', 'value' => 'CHtml::link($data->name, $data->site_url)', 'type' => 'raw', ), 回答1: Set the target attribute as _blank for the link ( <a> ) that will be generated: <a href="some_url" target="_blank">Foo</a> With CHtml::link : 'value' => 'CHtml::link($data->name, $data->site_url, array(

Toggle Column visibility in Yii Framework

时间秒杀一切 提交于 2020-01-17 11:16:29
问题 I'm using the CGridView widget to get data (39 columns) from a model, but the Table its way to large, i need to add a button to toggle some columns visible or not (lets say 20), maybe with jQuery, but i have no idea where to start, any ideas would be appreciated! <?php $this->widget('zii.widgets.grid.CGridView', array( 'id'=>'contacts-grid', 'itemsCssClass' => 'table table-striped table-bordered table-hover table-checkable table-responsive ', 'dataProvider'=>$model->search(), 'filter'=>$model

jQuery(…).yiiGridView is not a function

泪湿孤枕 提交于 2020-01-02 05:05:07
问题 I have a problem with Yii grid view. for some reason it does not seem to load correctly, even though the script is included (i can see it in the source code). This is the header part of the HTML: <script src="fileadmin/static/js/jquery-1.8.3.min.js" type="text/javascript"></script> <script src="/module/public/assets/80c0553/gridview/jquery.yiigridview.js" type="text/javascript"></script> <script type="text/javascript">jQuery(function($) { jQuery('#grid-downloads').yiiGridView({'ajaxUpdate':[

How to display data from related tables in CGridview in yii

末鹿安然 提交于 2020-01-01 03:39:24
问题 I am trying to display the results using CGridView. i have two tables Users and products . ExiProducts is the table which maintains the many to many relation between then and let the relation name is 'myrelation' public function actionSearch() { if(isset($_GET['searchButton'] && $_GET['searchType']==='products') { $searchString= trim(strip_tags($_GET['searchValue'])); $model=new Products; $criteria->compare('productName', $searchString, TRUE, 'AND', TRUE); $criteria->compare('productType',

关于Yii中CGridView关联表字段的filter问题解决方法

筅森魡賤 提交于 2019-12-30 22:29:55
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 当你想用CGridView控件来生成一个Grid表格的时候,是非常方便的,你只需要简单的指定几个属性就可以了,比如: $this->widget('zii.widgets.CGridView', array( 'id'=>'order-grid-view', 'dataProvider'=>$model->search(), 'filter'=>$model, 'columns'=>array( 'id', 'customer_cd' ), ) 问题是,当你需要多多表进行查询的时候,filter就需要多作一点工作了,很遗憾,我没有找到Yii官方对此问题的简易方法,所以,只能靠迂回的方式了。 首先,让关联表字段显示在Grid表格里面很容易,你可以在dataProvider属性加上关联表,然后columns属性里直接加上要显示的关联表属性就可以,比如,修改后的dataProvider为 'dataProvider'=>$model->with('relationNameToOtherTable')->search(), 修改后的columns属性为: 'columns'=>array( 'id', 'customer_cd', 'customer_nm'=>array( 'name'=>

Yii: Can not Display Data in Grid View

末鹿安然 提交于 2019-12-25 07:16:28
问题 I can't list data in grid using yii framework. My controller is Sitecontroller.php , My view is list_jobseeker.php . I got the error: Parse error: syntax error, unexpected '*', expecting ']' in C:\wamp\www\yii_new\framework\base\CComponent.php(612) : eval()'d code on line 1 Anybody give any suggestion to correct these issue? My controller: public function actionlist_jobseeker() { $session_id=Yii::app()->session['user_id']; if ($session_id == "") { $this->redirect( array('/employee/site/login'

CGridview custom field sortable

此生再无相见时 提交于 2019-12-24 03:51:40
问题 I had created with custom field in yii Cgridview but how to make that sortable. The custom field value is from a function in the model. I want to make this field sortable? Can someone help me? 回答1: In the search function of your model, where customField is the name of your field: // ...other criteria... $criteria->compare('customField',$this->customField); $sort = new CSort(); $sort->attributes = array( 'customField'=>array( 'asc'=>'customField ASC', 'desc'=>'customField DESC', ), '*', //

How to assign unique id attribute to each table row of a CGridView?

拈花ヽ惹草 提交于 2019-12-23 02:03:11
问题 I am attempting to assign a unique id to each table row in Yii's CGridView . Preferably something like $data->id from the database table. I have been unsuccessful at adding an id attribute to each rendered <tr> . Any suggestions would be most appreciated. 回答1: CGridView have an option called 'rowHtmlOptionsExpression' , you can declare like the followings to assign row an id 'rowHtmlOptionsExpression' => 'array("id"=>$data->id)', It's better than hacking into 'rowCssClassExpression' Good luck

How to print out from cgridview to csv?

两盒软妹~` 提交于 2019-12-12 03:46:15
问题 Q : How to print out the filtered data from cgridview to csv? Status : I followed instruction as here. But now I got the plane csv(excel) file. No header, no data. This is view <?php echo CHtml::button('Export', array('id'=>'export-button','class'=>'span-3 button')); ?> <?php $this->widget('zii.widgets.grid.CGridView', array( 'id'=>'request-grid', 'dataProvider'=>$model->creator(), 'filter'=>$model, 'columns'=>array( 'request_no', array( 'name'=>'request_type_id', 'value'=>'$data-

How to join three tables and get value in grid view

烂漫一生 提交于 2019-12-11 23:56:39
问题 I have three tables : contacts hasMany groups contact_groups hasMany contacts contact_contact_groups columns in table contact contact_id | contact_name columns in table contact_groups group_id | group_name columns in table contact_contact_groups contact_contact_group_id | contact_id | group_id MODEL contacs model public function getContactContactGroups() { return $this->hasMany(ContactContactGroups::className(), ['contact_id' => 'contact_id']); } contact_groups model public function