我能够过滤当我们单击子面板中的select
按钮时出现的记录。可以通过覆盖$initial_filter
值来完成,如下所示:
public function display($widget_data, $additionalFormFields = null, $nonbutton = false) {
global $app_strings; $initial_filter = '';
$initial_filter.='&SOME_FIELD='.urlencode("SOMEVALUE");
}
当弹出窗口打开时,该初始筛选器将用作$_GET
参数,以便它知道要显示哪些记录
现在棘手的部分是我试图弄清楚如何过滤它,以便它显示SOME_FIELD为空的记录......我尝试了类似SOME_FIELD=null
或SOME_FIELD=false
的东西,但它不起作用......如果有人可以提出任何建议,将不胜感激。
您需要修改列表视图查询和数据提取逻辑。查看以下详细信息以获取进一步帮助:
仅适用于列表视图:custom/modules/MODULE_NAME/views/view.list.php
以下是帮助代码:
require_once('include/MVC/View/views/view.list.php');
class MODULE_NAMEViewList extends ViewList {
function listViewProcess() {
global $current_user;
$this->params['custom_where'] = ' AND module_name.name = "test" ';
parent::listViewProcess();
}
}
对于列表和弹出视图(两者(:
您需要更改实际准备查询create_new_list_query
函数内部的逻辑。一些模块在 Bean 级别覆盖了它(例如,参见modules/Leads/Lead.php
(。
如果你想以升级安全的方式覆盖它,那么在自定义目录中创建一个文件,例如:custom/modules/Leads/Lead.php
,然后从核心 Bean 类扩展它,如下所示:
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
require_once('modules/Leads/Lead.php');
class CustomLead extends Lead {
function create_new_list_query($order_by, $where,$filter=array(),$params=array(), $show_deleted = 0,$join_type='', $return_array = false,$parentbean=null, $singleSelect = false, $ifListForExport = false)
{
// Code from create_new_list_query in and then modify it accordingly.
}
}
在此位置注册新的 Bean 类:custom/Extension/application/Ext/Include/custom_leads_class.php
和注册码如下所示:
<?php
$objectList['Leads'] = 'Lead';
$beanList['Leads'] = 'CustomLead';
$beanFiles['CustomLead'] = 'custom/modules/Leads/Lead.php';
?>