Yii grid

Some time ago there was an idea in the air that Yii 1.1 shall have a set of "official" extensions (now zii) and among these should have been a grid. Are there still plans to add an official grid implementation to zii in some near future?

Yes, working on it ATM.

When do you plan an alpha release?

I hope to get it done in the upcoming 1.1 RC release, which is in early December.

Thank you, Qiang, highly appreciated!

I’ve been working my way through the Zii widgets, fantastic stuff!

A grid would be a really excellent addition, are we talking jqgrid? I hope so, I see that 3.6 has just been released.

doodle

Just finished this: CGridView under zii. It is a home-grown one, with the main focus on integration with the existing AR, sorting and pagination features. It has the potential to be used in complex scenarios such as multiple datagrids, master-detail, etc. And it is highly configurable and extensible.

I also have a component based on jqGrid, but it is quite customized for a particular project and is not worth to be included in the core framework.

Thanks for that!

I’ve been just trying it out, but I can’t figure out how I should do a dateFormatter on a field.

I tried something like:




array(

    'dataField' => 'date',

    'dataExpression' => Yii::app()->dateFormatter->formatDateTime('date','medium',null),

),



and …




array(

    'dataField' => 'date',

    'dataExpression' => Yii::app()->dateFormatter->formatDateTime($data,'medium',null),

),



within the colums, but both don’t work…

Could you help me out here?

This must be a string, representing a PHP expression. So it should be:

‘dataExpression’ => ‘Yii::app()->dateFormatter->formatDateTime($data,“medium”,null)’

This is a nice widget. Could you consider allowing titles for the header cells of the CRudColumn

like




		array(

			'class'=>'CRudColumn',

                        'title'=>'Actions',


		),



and if title is not specified it should default to an empty string.

and a jquery modal using the zii extension for it for delete confirm since it’s already a part of the framework.

You can specify ‘header’ property since CRudColumn extends from CGridColumn.

I’m not sure if we should use jquery modal window for confirmation. One of the main goals of this component is extensibility. So everything is kept as simple as possible. Using jquery modal means using the whole JUI library, which may be a bit heavy for some people.

Thank you for your quick reply. It occurred to me just after i made the post that some people might not want to use JUI dialog modal.

Thanks.

I changed it. Output is not a date, but 0000, no matter what date.

On another field, a status field , I try a function that translates A or I in Active and Inactive. All fields are Active, but Inactive is displayed.




$this->widget('zii.widgets.grid.CGridView', array(

    'dataProvider'=>$dataProvider,

	'columns'=>array(

		array(

			'dataField'=>'status',

			'dataExpression'=>'DRView::translate("AI",$data)'

		),

		'status',

		array(

			'dataField' => 'date',

			'dataExpression' => 'Yii::app()->dateFormatter->formatDateTime($data,"medium",null)'

		),

		'date'

	),

));



has this output:




Status          Status  Date    Date

Inactive	A	0000	2009-09-01



Did I miss something?

it seems $data is an object and the field names are it’s attrubutes so you should use $data->fieldName eg. if your time field is createTime you would use


'dataExpression'=>'Yii::app()->dateFormatter->formatDateTime($data->createTime)',

Yes, $data refers to the AR object, rather than the individual attribute value.

Thanks! That’s it.

zii grid is will be useful! thank a lot!!

following is my first time to use zii grid’s question:

1.how can set the per page size?

2.how can set default sort order?

3.how can set columns per width? ( can be support percent? )

4.if set selectableRows=2 or above, how can get the selected rows?

like jqGrid powerful plug-ins for jquery, zii grid how to positioned?

http://www.yiiframework.com/extension/jqgrid/ i like this extension~

  1. You set it via data provider’s pagination property. For example,



$dataProvider=new CActiveDataProvider('Post', array(

    'pagination'=>array(    // every property of CPagination can be configured here

        'pageSize'=>20,

    ),

));



  1. Similar to 1: you configure it via data provider’s sort property.

  2. Setting table cell width is deprecated by XHTML standards. For this reason, you should use CSS to set column width (by selecting column CSS class).

  3. This is documented: $.fn.yiiGridView.getSelection(containerID)

Anyone has good table styles? I’d like to choose a better one as the default table style for CGridView.

Also, I added a new component called CDetailView. It needs a better style as well. Thanks.

Do you think it would be a good idea to have a "CListView"?