This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use Stack Overflow.

sfExtjs2Plugin Question

Forum to discuss ExtJS and other JS plugins

sfExtjs2Plugin Question

by swagner » Mon Feb 04, 2008 12:49 pm

when is use the code at the bottom for creating a CoulumnModel i get as output something like
Code: Select all
new Ext.grid.ColumnModel({{element},{element},{element},... }

but i should receive something like
Code: Select all
new Ext.grid.ColumnModel([{element},{element},{element},... ]

Which means the first array definition should create a '[' instead of a '{'. Does anyone hava a clue how i can get something like this using the sfExtjs2Plugin?
If not i cant use this plugin.

Code for creating the CoulumnModel with sfExtjs2Plugin:
Code: Select all

<?php use_helper('I18N', 'Javascript', 'sfExtjs2') ?>
<?php
$sfExtjs2Plugin = new sfExtjs2Plugin(array('theme'=>'gray'), array('css' => '/sfExtjsThemePlugin/css/symfony-extjs.css'));

$sfExtjs2Plugin->load();

// the column model has information about grid columns
// dataIndex maps the column to the specific data field in
// the data store
$cm = $sfExtjs2Plugin->ColumnModel(
     array(
         array(
               'id'     => 'viewuser',
               'header' => __("ansehen"),
               'hideable' => false,
               'width' => 50,
               'sortable' => false,
               'dataIndex' => 'ansehen'
               ),
         array(
               'header' => __("Rechte"),
               'hideable' => false,
               'width' => 50,
               'sortable' => false,
               'dataIndex' => 'editRights'
               ),
         array(
               'header' => __("Benutzer"),
               'width' => 100,
               'sortable' => true,
               'dataIndex' => 'username'
               ),
         array(
               'header' => __("Name"),
               'width' => 160,
               'sortable' => true,
               'dataIndex' => 'fullname'
               ),
         array(
               'header' => __("Prim&auml;rgruppe"),
               'width' => 120,
               'sortable' => true,
               'dataIndex' => 'primarygroup'
               ),
         array(
               'header' => __("Root"),
               'width' => 40,
               'sortable' => true,
               'dataIndex' => 'rootpriv'
               ),
         array(
               'header' => __("Erstellt am"),
               'width' => 100,
               'sortable' => true,
               'renderer' => 'Ext.util.Format.dateRenderer(\'d.m.Y H:i\')',
               'dataIndex' => 'createdAt'
               ),
         array(
               'header' => __("l&ouml;schen"),
               'hideable' => false,
               'width' => 50,
               'sortable' => false,
               'dataIndex' => 'deleteuser'
               )
         )
   );

...

swagner
Member
 
Posts: 46
Joined: Wed Oct 24, 2007 1:46 pm
Location: Munich, Germany

[Solved] sfExtjs2Plugin Question

by swagner » Mon Feb 04, 2008 3:37 pm

It was a bug in the Extjs2Plugin. We solved the problem by asking if an array has to be interpreted as hash or not.
Seems like there are not that many people using this extension, if so this bug would have been found earlier.

Code: Select all
   * Creates Javascript source for Extjs2.class
   *
   * @param array attributes
   * @param array config
   * @param array parameters
   * @return string source
   */
  public static function getExtObjectComponent($attributes = array(), $config = array(), $parameters = array(), $datas = array())
  {

    $isAssoc = false;

    foreach ( $attributes as $key => $skip ) {
   if ( !is_integer( $key ) ) {
            $isAssoc = true;
            break;
        }
    }

    $LBR_B_L = $isAssoc ? self::LBR_CB_L : self::LBR_SB_L;
    $LBR_B_R = $isAssoc ? self::LBR_CB_R : self::LBR_SB_R;

    $attributes = self::_build_attributes($attributes, $config['attributes']);
    $attributes = sprintf('%s', $attributes != '' ? $LBR_B_L.$attributes.$LBR_B_R : '');
 
    $parameters = implode(self::LBR_CM, $parameters);
    $datas = $config['class'] == 'anonymousClass' ? self::_build_datas($datas) : (!empty($datas) ? "'".implode("'".self::LBR_CM."'", $datas)."'" : '');
   
    switch ($config['class'])
    {
      case 'anonymousClass':
        $source = sprintf(
          '%s%s%s%s%s',
          $parameters,
          $parameters != '' && $datas != '' ? self::LBR_CM : '',
          $datas,
          $datas != '' && $attributes != '' ? self::LBR_CM : '',
          $attributes
        );
        return $source;

      case 'customClass':
        $source = sprintf(
          '{ %s }',
          $attributes
        );
        return $source;

      default:
        $source = sprintf(
          'new %s (%s%s%s%s%s)',
          $config['class'],
          $parameters != '' ? self::LBR_SB_L.$parameters.self::LBR_SB_R : '',
          $parameters != '' && $datas != '' ? self::LBR_CM : '',
          $datas,
          $datas != '' && $attributes != '' ? self::LBR_CM : '',
          $attributes
        );
        return $source;
    }
 
  }
swagner
Member
 
Posts: 46
Joined: Wed Oct 24, 2007 1:46 pm
Location: Munich, Germany

Re: [Solved] sfExtjs2Plugin Question

by lvanderree » Fri Mar 07, 2008 4:17 pm

The sfExtjs2Plugin is in active development, so that's probably why anyone else didn't find the problem yet...

Please post al your problems, comments and ideas in the sfExtjs thread to improve it (and to get replies earlier :roll: ): http://www.symfony-project.org/forum/index.php/m/47299/#msg_ 47299
Leon
User avatar
lvanderree
Faithful Member
 
Posts: 653
Joined: Sat Jun 02, 2007 9:32 pm
Location: Netherlands

Re: [Solved] sfExtjs2Plugin Question

by lvanderree » Wed Jul 23, 2008 1:43 am

Hi swagner, it was only up till now that I found your published patch in the sfExtjs2Plugin-wiki.

unfortunately it has become a little hard for me to merge your changes within the current svn version.

I use the sfExtjs2Plugin extensively (obviously, since it is one of the dependencies of the sfExtjsThemePlugin) and I've implemented other ways (hacks) to get around the problem you mentioned.

I don't know which one is nicer, but if you've got a patch for the current svn version, please let me know so I can merge it.

For more info about the latest state of the sfExtjsThemePlugin see the wiki: http://trac.symfony-project.org/wiki/sfExtjsThemePlugin

Or checkout my demo at http://tejohnston.dynora.eu/ (login with admin and admin )

Cheers
Leon
User avatar
lvanderree
Faithful Member
 
Posts: 653
Joined: Sat Jun 02, 2007 9:32 pm
Location: Netherlands

Re: [Solved] sfExtjs2Plugin Question

by swagner » Wed Jul 23, 2008 9:03 am

Sorry, actually i am working on another (non-symphony) project and my time is short. So i guess i won't have the time to fully check if my code should be included into the new svn-version. But as far as i can see from here my code is obsolete.

If i see that some more work is needed and if i find the time to develop a patch i'll let you know. But i doubt it.
swagner
Member
 
Posts: 46
Joined: Wed Oct 24, 2007 1:46 pm
Location: Munich, Germany

Re: sfExtjs2Plugin Question

by lvanderree » Wed Jul 23, 2008 11:39 am

No problem and Thanks for the reply ;)~ ;-)~ :wink:

At the moment everything is working fine for me, but after I found your patch I was sorry for not including it... It looked like another good solution.

Ciao
Leon
User avatar
lvanderree
Faithful Member
 
Posts: 653
Joined: Sat Jun 02, 2007 9:32 pm
Location: Netherlands