Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

problem with orderField #491

Open
imonteiro opened this issue Jan 18, 2013 · 5 comments
Open

problem with orderField #491

imonteiro opened this issue Jan 18, 2013 · 5 comments

Comments

@imonteiro
Copy link
Member

Original author: [email protected] (August 12, 2010 20:38:01)

$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: http://code.google.com/p/zfdatagrid/issues/detail?id=414

@imonteiro
Copy link
Member Author

From [email protected] on December 15, 2010 23:18:08
Hi,

Can you please check if this still happens?

Best Regards,
Bento Vilas Boas

@imonteiro
Copy link
Member Author

From [email protected] on December 18, 2010 22:33:00
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..

@imonteiro
Copy link
Member Author

From [email protected] on January 26, 2011 05:27:42
Hi,

Finally I got it.

Please update your code to latest revision

Best Regards,
Bento Vilas Boas

@imonteiro
Copy link
Member Author

From [email protected] on February 22, 2011 16:06:10
It is still happening , but only to the column with position 1.

@imonteiro
Copy link
Member Author

From [email protected] on February 22, 2011 16:18:48
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();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant