Hi Saganxis,

Even though the code-style of the SympalGrid is quiet different from
sfGrid and the SympalGrid is also extremely coupled to Doctrine (which
I think is a pity since it is limiting the possible use-cases), I do
like the way templates and especially partials are being used to
render the grid. This can probably simplify the usage a bit (although
I have to see if it isn't over simplified for the usages I have in
mind. For instance the Widgets that are used in the grid make it
possible to combine data from several fields and allow to add
(complex) data manipulation to the grid before rendering).

For now I first want to finish my demo together with the extjs-grid-
renderer. And maybe use the routing engine more extensively, but I am
open for suggestions on how to improve and maybe simplify the grid.



On 12 apr, 17:30, Saganxis <dias...@gmail.com> wrote:
> Hi, maybe you could get some ideas from the sympal DataGrid Plugin.
> Here is the 
> codehttp://redmine.sympalphp.org/projects/sympal/repository/revisions/mas...
> here the docshttp://www.sympalphp.org/documentation/1_0/book/data-grid/en
>
> On Apr 12, 10:11 am, E_lexy <alexk...@gmail.com> wrote:
>
> > Leon,
>
> > I just checked out all required plugins to generate a grid.
> > Using your old sfGridExtjs3plugin, i get inheritance errors.
> > it seems the sfGrid class variables cannot be reached by any subclass
> > (private).
> > When I change them to 'protected' the subclasses are allowed access
> > and all works fine.
>
> > p.s. i am very curious to see your extjs grid plugin, I have am using
> > old plugin so I can specify EXtjs column plugins is the meta data, and
> > have Extjs generate the entire grid based on the 
> > jsonhttp://www.extjs.com/deploy/dev/docs/source/Store.html#cls-Ext.data.S...
>
> > Alex
>
> > On Apr 12, 11:03 am, DigitalBase <i...@digitalbase.eu> wrote:
>
> > > Leon,
>
> > > i am trying out your sfGrid plugin and ran into few small issues
> > > where do you want us to report problems/bugs ?
>
> > > On Apr 11, 10:53 pm, Leon van der Ree <l...@fun4me.demon.nl> wrote:
>
> > > > Today I will provide a tutorial, setting up a (propel-based)
> > > > playground with some best practices I came up with so far. (If you
> > > > prefer Doctrine, you can still follow the tutorial, but of course need
> > > > to setup a Doctrine schema and use the Doctrine plugins)
>
> > > > If you want to see where all the fuzz is about, peak ahead and look at
> > > > the size of the controller and the template!
> > > > All configuration can be done in an extended
>
> > > > Lets begin with a new (Symfony 1.4) Project:
>
> > > > Tip: create a new repository on your svn-server and check this out!
> > > > (this is useful since we are using a lot of plugins from svn, that can
> > > > be updated all at once by using svn:externals )
>
> > > >   svn co your.svn.server/playground-project playground
> > > > or, when not using svn
> > > >   mkdir playground
>
> > > >   cd playground
> > > >   php /symfony14/data/bin/symfony generate:project --orm=propel
> > > > playground
>
> > > > we now have a new propel-based syfmony 1.4 project. Lets start by
> > > > adding all required Plugins:
>
> > > >   svn propedit svn:externals .
>
> > > > and add the following lines to it:
>
> > > > plugins/sfPropel15Pluginhttp://svn.symfony-project.com/plugins/sfPropel15Plugin/trunk
> > > > plugins/sfPropelObjectPathBehaviorPluginhttp://svn.symfony-project.com/plugins/sfPropelObjectPathBehaviorPlug...
> > > > plugins/sfDataSourcePlugin  
> > > > http://svn.symfony-project.com/plugins/sfDataSourcePlugin/trunk
> > > > plugins/sfGridPluginhttp://svn.symfony-project.com/plugins/sfGridPlugin/trunk
>
> > > > Now we enable our plugins, first by editing our Project configuration,
>
> > > > edit config/ProjectConfiguration.class.php
> > > > and enable your plugins in the setup-function:
>
> > > >     $this->enablePlugins(
> > > >         'sfPropel15Plugin',
> > > >         'sfPropelObjectPathBehaviorPlugin',
>
> > > > //      'sfExtjs3Plugin', // soon people
>
> > > >       'sfDataSourcePlugin',
> > > >       'sfGridPlugin' //,
> > > > //      'sfGridExtjsPlugin' // soon.... Just teasing ;)
> > > >     );
>
> > > > Setup propel, by editing propel.ini
> > > > please note propel1.5 is requiring different behavior-paths and we are
> > > > enabling the object-path plugin:
> > > > So the behaviors section should look like this:
>
> > > > ; behaviors
> > > > propel.behavior.default                        =
> > > > symfony,symfony_i18n,object_path
>
> > > > propel.behavior.symfony.class                  =
> > > > plugins.sfPropel15Plugin.lib.behavior.SfPropelBehaviorSymfony
> > > > propel.behavior.symfony_i18n.class             =
> > > > plugins.sfPropel15Plugin.lib.behavior.SfPropelBehaviorI18n
> > > > propel.behavior.symfony_i18n_translation.class =
> > > > plugins.sfPropel15Plugin.lib.behavior.SfPropelBehaviorI18nTranslation
> > > > propel.behavior.symfony_behaviors.class        =
> > > > plugins.sfPropel15Plugin.lib.behavior.SfPropelBehaviorSymfonyBehaviors
> > > > propel.behavior.symfony_timestampable.class    =
> > > > plugins.sfPropel15Plugin.lib.behavior.SfPropelBehaviorTimestampable
>
> > > > propel.behavior.object_path.class              =
> > > > plugins.sfPropelObjectPathBehaviorPlugin.lib.ObjectPathBehavior
>
> > > > Currently I have a simple schema as an example:
>
> > > > propel:
> > > >   city:
> > > >     id:
> > > >     name:       varchar(255)
> > > >     country_id:
> > > >     created_at:
>
> > > >   country:
> > > >     id:
> > > >     name:      varchar(255)
> > > >     created_at:
>
> > > > lets build the model
>
> > > >   ./symfony propel:build-all
>
> > > > Add an application and empty module:
>
> > > >   ./symfony generate:app frontend
> > > >   ./symfony generate: frontend cityGrid
>
> > > > Now add a grid folder to your lib-folder and add a CityGrid.php file
>
> > > >   mkdir lib/grid
> > > >   edit lib/grid/CityGrid.php
>
> > > > and add the following code to it:
>
> > > > <?php
> > > > class CityGrid extends sfWebGrid  // soon you can extend the
> > > > sfGridExtjs3 - class
> > > > {
> > > >   /**
> > > >    *
> > > >    * @param sfWebRequest $request
> > > >    */
> > > >   public function __construct(sfWebRequest $request)
> > > >   {
> > > >     $cityDataSource = new sfDataSourcePropel('City');
> > > >     parent::__construct($cityDataSource);
>
> > > >     $this->setDefaultSort('Country.Name', sfGrid::ASC);
>
> > > >     $this->setColumns(array(
> > > >       'Id',
> > > >       'Country.Name',
> > > >       'Name'
> > > >     ));
>
> > > >     $this->setColumnTitles(array(
> > > >       'Country.Name' => 'Country',
> > > >       'Name'         => 'City'
> > > >     ));
> > > >     $this->setSortable(sfGrid::ALL);
>
> > > >     $this->getPager()->setMaxPerPage(2);
> > > >     $this->bind($request);
> > > >   }
>
> > > > }
>
> > > > Now you can add the following to your controller:
>
> > > > edit actions.class.php
>
> > > >  /**
> > > >   * Executes index action
> > > >   *
> > > >   * @param sfRequest $request A request object
> > > >   */
> > > >   public function executeIndex(sfWebRequest $request)
>
> > > >     $this->grid = new CityGrid($request);
>
> > > >   }
>
> > > > And edit your template, indexSuccess.php
>
> > > > <?php $grid = $sf_data->getRaw('grid'); ?>
> > > > <div id="grid-example">
> > > >   <table>
> > > >    <?php echo $grid->render() ?>
> > > >   </table>
> > > > </div>
>
> > > > clear your cache
>
> > > >   ./symfony cc
>
> > > > add some data to your database, use fixtures, or the following:
>
> > > > // initialize database
> > > > $country_nl = new Country();
> > > > $country_nl->setName('the Netherlands');
>
> > > > $country_fr = new Country();
> > > > $country_fr->setName('France');
>
> > > > $country_be = new Country();
> > > > $country_be->setName('Belgium');
>
> > > > $city_ams = new City();
> > > > $city_ams->setCountry($country_nl);
> > > > $city_ams->setName('Amsterdam');
> > > > $city_ams->save();
>
> > > > $city_rdm = new City();
> > > > $city_rdm->setCountry($country_nl);
> > > > $city_rdm->setName('Rotterdam');
> > > > $city_rdm->save();
>
> > > > $city_rdm = new City();
> > > > $city_rdm->setCountry($country_nl);
> > > > $city_rdm->setName('Den Haag');
> > > > $city_rdm->save();
>
> > > > $city_prs = new City;
> > > > $city_prs->setName('Paris');
> > > > $city_prs->setCountry($country_fr);
> > > > $city_prs->save();
>
> > > > $city_bdx = new City;
> > > > $city_bdx->setCountry($country_fr);
> > > > $city_bdx->setName('Bordeaux');
> > > > $city_bdx->save();
>
> > > > $city_brs = new City();
> > > > $city_brs->setCountry($country_be);
> > > > $city_brs->setName('Brussel');
> > > > $city_brs->save();
>
> > > > next time I will release the extjsGrid. Then I will transform this
> > > > example to ExtJS, with only minor changes to the module and the
> > > > CityGrid-class.The CityGrid will specialize the ExtjsGrid, providing
> > > > it the capabilities to generate not only HTML, but JSON and JS output
> > > > as well. The controller currently needs to be altered to add support
> > > > to handle .js and .json requests, but I am going to make the routing
> > > > engine take care of that. The template currently needs to be extended
> > > > as well, to start the initial extjs-application, but this will be
> > > > moved to the extjs-grid-plugin soon as well.
>
> > > > For now I would be happy to get feedback about the current HTML
> > > > formatter.
> > > > I didn't explained how to modify the (row)formatter yet and how to
> > > > define and write widgets, but you should be aware that these are the
> > > > key to modifying the HTML rendering (for example to add css-classes
> > > > and truncate your texts or format currencies) to your liking.

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en

To unsubscribe, reply using "remove me" as the subject.

Reply via email to