开发者

Symfony: a way to show/hide list rows in action?

开发者 https://www.devze.com 2023-03-30 04:44 出处:网络
i try to make set of actions that work similar to Index action, but they show filtered data (some kind of readymade reports).

i try to make set of actions that work similar to Index action, but they show filtered data (some kind of readymade reports).

So far I figured out something like this::

public function executeReport(sfWebRequest $request)
{ 
  $this->setFilters(array('field'=>'value'));

  $this->forward($this->getModuleName(), 'index');
}

but I also want to modify the set of columns.

Default set is stored in generator.yml

generato开发者_运维百科r:
  param:
    config:
      list:
        display: [field1, field2, field3]

is there any way to set only field2 and field3 visible inside executeReport()?


You can override your generator configuration in module/lib/moduleGeneratorConfiguration.class.php:

The method that is used to fetch the fields is this:

public function getListDisplay()
{
  return array('field2','field3');
}

I've not tested it, but you should be able to override that with different values like this:

public function getListDisplay()
{
  return sfConfig::get('app_my_columns');
}


Modify your template ReportSuccess.php with only the fields that you need.


maybe i'm wrong but if you hide attributes you are not hiding any row, you'll be hiding columns. To hide/show rows you can do it on the template file with an structure similar to this:

foreach($row_you_can_show as $row){
    if(you_want_to_show($row)){
         echo "<tr>...</tr>";
    }
}

If you want to control it dynamically you can do it with a javascript function, but is more complicated....

good luck

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号