Cgridview

CJuiDatePicker in CGridview as form field

落花浮王杯 提交于 2019-12-11 18:06:31
问题 I am displaying form elements in my CGridView and would like datepicker, but it complains CDataColumn and its behaviors do not have a method or closure named "widget". I have modified DATEIN using the method described in Use a widget in a statically-called method However i think it works partially as when i do a sort or the datepicker does not work. its working only on initial load. <script> $(document).ready(function() { /* $("input[name*='DATEIN'] ").each(function(){ jQuery(this).datepicker

yii cgridview Property “CActiveDataProvider.abc” is not defined

徘徊边缘 提交于 2019-12-11 11:23:57
问题 In my controller: $model = new Sheets(); $criteria = new CDbCriteria; $criteria->compare('id', $model->id); $criteria->compare('track_name', $model->track_name, true); $criteria->addCondition('user_id = '.Yii::app()->user->getId().' and '.$listSetups[$i]['condition']); $setups = new CActiveDataProvider($model, array('criteria' => $criteria)); In my view: <?php $this->widget('zii.widgets.grid.CGridView', array( 'id' => 'sheets-grid', 'dataProvider' => $model, //'filter' => $model, 'template'=>

CGridview conditional delete button

放肆的年华 提交于 2019-12-10 12:38:00
问题 I want the delete button to be active only in certain condition in CGgridView CButtonColumn (or make a custom delete button) e g if user=='admin' or status=='draft' . Any ideas? Thanks! 回答1: use 'visible' parameter - 'buttons'=>array ( 'delete' => array ( 'label'=>'Delete', //other params 'visible'=>!Yii::app()->user->checkAccess('admin'), ), 回答2: 'visible'=>'$data->status=="draft" || Yii::app()->user->checkAccess("admin")' 回答3: You can also use anonymous function if PHP >= 5.3 'visible'=

Unable to set pageSize for pager in CGridView - Yii

痴心易碎 提交于 2019-12-10 11:03:39
问题 I am trying to set the pageSize property of pager in CGridView but in vain. By the way currently there are total of 2 items, i want to display only 1 on 1 page. Thanks. <?php $this->widget('zii.widgets.grid.CGridView', array( 'id'=>'user-grid', 'pager' => array( 'pageSize' => 1, ), 'dataProvider'=>$model->search(), 'filter'=>$model, 'columns'=>array( 'id', 'username', 'email', 'pass', 'type', 'date_entered', array( 'class'=>'CButtonColumn', ), ), )); ?> 回答1: remove the following from the view

Yii CGridView rendered inside CJuiDialog won't be filtered or ordered

流过昼夜 提交于 2019-12-08 13:30:06
问题 I'm rendering a CGridView inside a CJuiDialog, and that's working fine. My problem is, every time i click a column header to sort records, the page changes (the url is the url of the view rendered with renderPartial through ajax) and the request is not ajax ( Yii::app()->request->isAjaxRequest inside the controller is false). Also, if i filter any field, nothing happens. How can I let the user sort or filter the CGridView? OR: Is there another way to let the user choose a Foreign Key field

Yii booster: how to render a cgridview inside a relation table row?

天涯浪子 提交于 2019-12-08 09:48:11
问题 I'm using boostrap library on Yii via yii-booster I've created a relation table view The related view is a TbGriView itself Vhen in a row i click on the link on the 'related' column, the row expands itself, and render a TbGridview inside it. The problem is that the internal gridview cannot be sorte, paged or filtered, because each action on it causes that the entire container grid will empty Note - external grid as a id of 'extenalgrid' - each internal grid has as id like 'internalgrid-$rowId

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

醉酒当歌 提交于 2019-12-07 07:16:27
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. 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 ! Modern solution (since Yii 1.1.13) This is now possible to do using the rowHtmlOptionsExpression

Unable to set pageSize for pager in CGridView - Yii

别来无恙 提交于 2019-12-06 10:59:39
I am trying to set the pageSize property of pager in CGridView but in vain. By the way currently there are total of 2 items, i want to display only 1 on 1 page. Thanks. <?php $this->widget('zii.widgets.grid.CGridView', array( 'id'=>'user-grid', 'pager' => array( 'pageSize' => 1, ), 'dataProvider'=>$model->search(), 'filter'=>$model, 'columns'=>array( 'id', 'username', 'email', 'pass', 'type', 'date_entered', array( 'class'=>'CButtonColumn', ), ), )); ?> remove the following from the view 'pager' => array( 'pageSize' => 1, ), inside the dataprovider array in your model search method add this

Yii 关于CSqlDataProvider和CGridView的合并使用

你说的曾经没有我的故事 提交于 2019-12-05 12:04:23
今天遇到个问题,我将CSqlDataProvider数据代入CGridView的时候,数据能正常使用,但按钮就不能使用了,会提示出错。 问过些朋友,原来sqlDataProvider 中的数据集 是一个二维数组,原始的CGRidView 里面的CColumnButton 默认用的是一个Ar 但你用sqlDataProvider后就变成了关联数组了。所以 url生成那里就出错了。 $data 可能表示一个AR 或者是一个数组 当用SqlDataProvider ,ArrayDataProvider 时就是一个数组,这时候 CButtonColumn 的三个默认url 就需要自己手动修改了 不然就出错了 下面附上一段自动生成 CGridView的代码,只需要将你得到的 CSqlDataProvider数据输入即可。 /** * @param CSqlDataProvider $dp * 针对CSqlDataProvider自动生成CGridView的代码 */ static public function gridView4sqlDataProvider(CSqlDataProvider $dp) { $rowSet = $dp->getData(); $firstRow = array(); if (!empty($rowSet)) { $firstRow = current(

jQuery(…).yiiGridView is not a function

ⅰ亾dé卋堺 提交于 2019-12-05 10:07:47
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':['grid-downloads'],'ajaxVar':'ajax','pagerClass':'pager','loadingClass':'grid-view-loading','filterClass'