omusico / zfdatagrid

Automatically exported from code.google.com/p/zfdatagrid
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

problem with orderField #414

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
$select = $db->select ();
$select->from ( 'oferts');
$select->joinLeft ( 'images', 'oferts.oferts_id=images.img_ofert_id' );
$grid->setSource ( new Bvb_Grid_Source_Zend_Select ( $select ) );
$grid->setColumnsHidden ( $grid->getFields () );

$grid->updateColumn ( 'img_name', 
            array (     
                'title' => 'ID', 
                'orderField' => 'ofert_id', 
                'hidden' => 0, 
                ) );

Hi. I think there is an issue with orderField feature for columns. If I set it 
like it is in the code aboive, it will not work. 
$select = $db->select ();
$select->from ( 'oferts');
$select->joinLeft ( 'images', 'oferts.oferts_id=images.img_ofert_id' );
$grid->setSource ( new Bvb_Grid_Source_Zend_Select ( $select ) );
$grid->setColumnsHidden ( $grid->getFields () );

$grid->updateColumn ( 'img_name', 
            array (     
                'title' => 'ID', 
                'orderField' => 'ofert_id', 
                'hidden' => 0, 
                ) );

I didn't debug a lot , but i noticed that in file Grid.php, function 
_buildTitles () , if i dump  
Zend_Registry::get('log')->info($this->_fields);    
Zend_Registry::get('log')->info($this->_resetKeys($this->_data['fields']));

, the first value from $this->_fields is img_name, when the first value of
$this->_resetKeys($this->_data['fields']) is oferts_id . 

To notice the problem, just dump the return value of the _buildTitles function, 
and you will see the orderField is not setup for the column where i setup the 
orderField. Just make sure, when you select, select all the values from your 
test table, make the all hidden using $grid->setColumnsHidden ( 
$grid->getFields () ); , and after that setup orderField and hidden=0 for your 
column. 

I hope I explained the problem well.

Thank you. 

Original issue reported on code.google.com by rbejen...@gmail.com on 12 Aug 2010 at 8:38

GoogleCodeExporter commented 9 years ago

Original comment by bento.vi...@gmail.com on 18 Aug 2010 at 10:45

GoogleCodeExporter commented 9 years ago
Hi,

Can you please check if this still happens?

Best Regards,
Bento Vilas Boas

Original comment by bento.vi...@gmail.com on 15 Dec 2010 at 11:18

GoogleCodeExporter commented 9 years ago
Hi. Yes , the bug is still there. 

Just test it with this simple code:

$db = Zend_Db_Table_Abstract::getDefaultAdapter();
        $grid_config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/admin/grid.ini', 'production');
        $grid = Bvb_Grid::factory('table', $grid_config, $id = '');
        $grid->setRowAltClasses("odd", "even");
        $grid->setRecordsPerPage(20);
        $grid->setNoFilters(0);
        $select = $db->select();
        $select->from('articles', array(
                                        "*"
        ));

        $grid->setSource(new Bvb_Grid_Source_Zend_Select($select));
        $grid->setColumnsHidden($grid->getFields());
        $grid->updateColumn('article_title',
                            array(
                                'style' => 'width:45%',
                                'title' => 'Title',
                                'orderField'=> 'article_id'
                                'position' => 1, 
                                'hidden' => 0
                            ));

        $this->view->grid = $grid->deploy();
I just checked with the latest code from svn, and the orderField is not 
working, the column is still ordering after article_title from the case above, 
not article_id..

Original comment by rbejen...@gmail.com on 18 Dec 2010 at 10:33

GoogleCodeExporter commented 9 years ago
Hi,

Finally I got it.

Please update your code to latest revision

Best Regards,
Bento Vilas Boas

Original comment by bento.vi...@gmail.com on 26 Jan 2011 at 5:27

GoogleCodeExporter commented 9 years ago
It is still happening , but only to the column with position 1.

Original comment by rbejen...@gmail.com on 22 Feb 2011 at 4:06

GoogleCodeExporter commented 9 years ago
There is a problem i noticed it now. 
When you setup order=false to the column from first position, at the second 
column you have the orderField for first Column.  I think it is still an issue 
here, the orderField from first column is not read, and if i setup the order to 
false, then it is read to second column...

$db = Zend_Db_Table_Abstract::getDefaultAdapter();
        $grid_config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/admin/grid.ini', 'production');
        $grid = Bvb_Grid::factory('table', $grid_config, $id = '');
        $grid->setRowAltClasses("odd", "even");
        $grid->setRecordsPerPage(20);
        $grid->setNoFilters(0);
        $select = $db->select();
        $select->from('articles', array(
                                        "*"
        ));

        $grid->setSource(new Bvb_Grid_Source_Zend_Select($select));
        $grid->setColumnsHidden($grid->getFields());
        $grid->updateColumn('article_title',
                            array(
                                'style' => 'width:45%',
                                'title' => 'Title',
                                 'order'=>false,
                                'orderField'=> 'article_id'
                                'position' => 1, 
                                'hidden' => 0
                            ));
        $grid->updateColumn('article_content',
                            array(
                                'style' => 'width:45%',
                                'title' => 'Title',
                                'orderField'=> 'article_date'
                                'position' => 2, 
                                'hidden' => 0
                            ));

        $this->view->grid = $grid->deploy();

Original comment by rbejen...@gmail.com on 22 Feb 2011 at 4:18

GoogleCodeExporter commented 9 years ago

Original comment by bento.vi...@gmail.com on 28 Feb 2011 at 5:47