Closed qiangxue closed 10 years ago
What I would really like in the gridview provided by Yii is some of the improvements that @tonydspaniard made available in the Extended Gridview from YiiBooster. Especially the responsive table features and the sticky header option. Gridview, Itemview and menu are really bread and butter widgets - I would be disappointed to see them go. Datatables, SlickGrid, JQGrid, etc. are not really impressive enough IMO. Most people, I think, are using the GridView widget and extending it.
May I ask where in the framework folder structure is the GridView located? in framework/widgets?
It's nowhere now.
I am unsure where to place it...
framework/widgets
is fine for the start. We can always move it. It's pre-release time.
Should we build our own data grid like in 1.1 or integrate a popular one from 3rd party?
It would be nice to have something like this (a ruby gem): http://wicegrid.herokuapp.com/
That is, almost like CGridView, but with:
well there were one cool extension know to russian community - http://jqgrid-php.net/doku.php. Also i think some improvements can be made in filtering area, also some columns classes can be taken from yiibooster, yiistrap, yiiwheels, to support inline-edit and other cool things.
I think the CGridView is an amaizing and very useful widget, the only thing that it needs from my point of view is avoid to generate the entire page when is loaded by ajax call. It would be great if we can have a property for ajax requests that returns data in json format. (sorry for my English)
+1 -> 3d party Unless you want to expend more time on it.
@qiangxue you mean building a widget on top something like the following?
http://handsontable.com/index.html https://github.com/mleibman/SlickGrid
since we're talking about 3rd party grids...
you guys might find interesting to add to the stack Datatables.
A table plugin for jQuery: https://datatables.net/
PS - I really like CGridView in 1.1, in fact was a driving factor to try out yii in the first place.
Should we build our own data grid like in 1.1 or integrate a popular one from 3rd party?
Ofcourse own. Same as in 1.1 but with possibility to set column types as classes.
I think our own solution would be better. These grids are all (or most of them) jQuery add-ons, means JavaScript. They care little for where the data actually comes from making joins, concatenation of fields, etc. sometimes hard. WiceGrid seems to be the only one that tackles this issues, however it's ruby so we can't build on top of this anyway. Grids in 1.1 are nice already, however, I think these 3rd party grids give good ideas what could be implemented additionally.
I'am for making an own solution!
After reading some users opinions, I have to say I would go for a custom solution too.
But I think the funcionallity has to be discussed, I didn't love the Yii 1.1 grid.
Please remove the eval
when writing column values and re-think the overall syntax...
@lucianobaraglia any concrete suggestions about the syntax?
Please remove the eval when writing column values and re-think the overall syntax..
use closure.
@samdark I will think about it and give my thoughts but trust more in your good criteria! :)
Change evaluated strings to access of the current row (even if it could involve some magic), e.g.:
array( // display 'create_time' using an expression
'name'=>'create_time',
'value'=>'date("M j, Y", $data->create_time)',
),
some syntax ideas for column values:
array(
'header' => 'Created',
'value' => date("M j, Y", $model->create_time), // could this be possible access $model for each row?
),
// maybe calling a method from the model
array(
'header' => 'Created',
'value' => $model->dateForHumans(), // called method: return date("M j, Y" $this->created_time);
),
// or rendering a partial
array(
'header' => 'Created',
'value' => $this->renderPartial('_date_partial', array('model' => $model)), // partial would be: echo date("M j, Y" $model->created_time);
),
// or rendering a partial with the $model variable passed automaticly
array(
'header' => 'Created',
'value' => $this->renderPartial('_date_partial'), // partial would be: echo date("M j, Y" $model->created_time);
),
@lucianobaraglia it is already possible in yii1.1 to use anonymous functions there:
array(
'header' => 'Created',
'value' => function($model) { return date("M j, Y", $model->create_time); }
),
@cebe he ignored my message lol, dont think that see yours =D
@Ragazzo I didn't ignore anything, just don't want to convert this in a chat...
@lucianobaraglia
After reading some users opinions, I have to say I would go for a custom solution too.
Are you sure custom solutions will be better??? You really think so??? We have one of bestest grid. But you suggest use 3rd party (mostly bull$...t) without even show it pros in compare with ours.
some syntax ideas for column values
Oh, man. Seems you dont know how to use our grid if you make such suggestions. Please learn it more and only after make any conclusions about it.
@creocoder easy, tiger...
@samdark
any concrete suggestions about the syntax?
Yes, ofcourse. All like in Yii 1.1.x but with allowing to refedine builtin types and allowing to set column by class:
'types' => array(
'image' => 'creocoder\yii\grid\ImageColumn', // we define new type here
'data' => 'creocoder\yii\grid\MyCustomDataColumn', // by doing this we override builtin type
),
'columns' => array(
array(
'class' => 'creocoder\yii\grid\MyColumn',
...,
),
array(
'type' => 'image',
...,
),
'someField', //use `creocoder\yii\grid\MyCustomDataColumn`,
array( // here we use data column and `format` is its param
'format' => 'text',
...,
),
),
Slickgrid is one of the best grid I've used, it would be very nice if Yii2 could support it out of the box.
@creocoder not so big enh. with new classes, you always can pass class
option as you know, it is more like syntax sugar.
@Ragazzo Yes, but allowing to define own types is some kind of DI and this allow to make reusable grids. You can preconfigure types in application configuration like we do it in widgetFactory in Yii 1.1.x
@Ragazzo Here is more complex example:
'types' => array(
'data' => array(
'class' => 'yii\widgets\grid\DataColumn',
'format' => 'ntext',
),
),
By doing this we change default DataColumn format
property.
not so big enh
Yes, not so big, but it give new features. Another example:
'types' => array(
'button' => array(
'class' => 'yii\widgets\grid\ButtonColumn',
'buttons' => array(
'view' => array(
'imageUrl' => 'zoom.png',
),
'update' => array(
'imageUrl' => 'pencil.png',
),
),
),
),
By doing this you can ONCE preconfigure all application button types with icons and not configure icon in every grid.
It should also be able to add nested grids and "select all" delete functionality.
@creocoder
After reading some users opinions, I have to say I would go for a custom solution too.
Are you sure custom solutions will be better??? You really think so??? We have one of bestest grid. But you suggest use 3rd party (mostly bull$...t) without even show it pros in compare with ours.
With custom solution, I meant custom YII solution.
As I understand, using third-party clientside solution doesn't change anything about our usage of data-providers, configuring columns etc.
@samdark I suposse it be that way...the grid used shouldn't change the yii grid api...
@creocoder whats better about defining types in grid instead of creating new Formatter method?
@cebe How this feature related to Formatter? I see no any relations here...
@cebe In types we define column types. This is not format.
format is only property for DataColumn (or another column types). Grid works with columns, it know nothing about formats.
I don't know why you don't embed such a grid like in http://www.jqwidgets.com
check the demo here: http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxgrid/index.htm#demos/jqxgrid/createremoveupdatedata.htm
it's awesome
json grid would be great.... if that would be the case would the ajax call that generates the whole html page be taken-off? and the grids would base solely on JSON formatted Dataproviders
This is probably the wrong place for this but I don't know if a new issue should be created. Is there any way that content that implements Ajax calls (pagination and such) could have the options of modifying the URL? The idea is to enable linking URL or even simply using the back button to go back to the content you want. ex: user goes to page 6 of grid, views details for an item and clicks back in browser. This should land the user on page 6 even if the content was loaded via Ajax calls.
We are thinking to use pjax (issue #706) to solve this problem.
also, can we make gridview and maybe even baselistview with infinite-js-scroll?
What is infinite-js-scroll? Any reference?
just like twitter/facebook newslines, the most popular js extension is this: https://github.com/paulirish/infinite-scroll but will be great if we will have it in Yii2 by default. There are some implementations for Yii1 but they dont looks so good.
I think the requirement for this is not generic enough to be supported at the core.
Agree.
i'm agree with @fernandezekiel, json grid would be great...
Why do you want json grid? What is in the json result? How would you format the json result into grid cell contents? How to deal with more complex grid structures, such as merged cells, alternating rows?
Would be good to find a better approach than a replacement of HTML elements. Would be nice if new widgets do work with JSON and updates on the client be done with proper Javascript libraries.
Instead of creating our own, would be nice to work in conjunction with others that prove better functionality, ie DataTables or SlickGrid or JQGrid. There are many out-there.
It is good that Yii2 is thinking about implementing widgets as it was with Zii, but I am personally not sure whether the widgets belong to the core or to an external library.
By using composer, we can build an external library (such as YiiBooster or Yii-Bootstrap did) and inject the requirements to the project as proposed by http://yiinitializr.2amigos.us.
Maybe is a good idea to separate Yii2 Core from the libraries that provide fast development such it was zii.