symfony doctrine管理生成器 - >自定义列表 [英] symfony doctrine admin generator -> custom listing
本文介绍了symfony doctrine管理生成器 - >自定义列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我还没有找到一种方法来定制列表视图中显示的项目。
要更具体一点:默认情况下,选择和显示数据库表中的所有记录,我想能够调整一点数据库选择,以便仅从表中选择一个项目的子集。
解决方案
config:
list:
table_method:getForAdminList
然后,在相关的模型表类中,您可以定义过滤记录的条件:
public function getForAdminList()
{
$ q = $ this-> createQuery('a')
- > where('a.id>?',100);
return $ q;
}
请注意,您必须返回查询,而不是收集记录。 / p>
I haven't found a way yet to customize what items are shown in the "list" view. To be a little bit more specific : by default all the records in a database table are selected and displayed, I want to be able to tweak a little the database select in order to select only a subset of items from the table.
解决方案
config:
list:
table_method: getForAdminList
Then, in a related model table class you can define your conditions to filter records:
public function getForAdminList()
{
$q = $this->createQuery('a')
->where('a.id > ?', 100);
return $q;
}
Notice that you have to return the query, not a collection of records.
这篇关于symfony doctrine管理生成器 - >自定义列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文