我认为您无法像在 EditView 和 DetailView 中那样在 ListView 中获得相同的结果。解决此问题的一种方法是将非 db 字段添加到 Leads vardefs 并使用逻辑挂钩来处理条件格式。
创建一个新的 vardef:
/custom/Extension/modules/Cases/Ext/Vardefs/my_listview_value_c.php
<?php
$dictionary['Lead']['fields']['my_listview_value_c'] = array(
'name' => 'my_listview_value_c',
'vname' => 'LBL_MY_LISTVIEW_VALUE_C',
'type' => 'varchar',
'len' => '255',
'source' => 'non-db',
);
?>
创建逻辑挂钩:
/custom/modules/Leads/ListViewLogicHook.php
<?php
class ListViewLogicHook {
public function getListValue(&$bean, $event, $arguments) {
if ($bean->ld_assumed_sugar_account_id_c) {
$bean->my_listview_value_c = $bean->account_name;
} else {
// Whatever you'd like
}
}
}
添加逻辑钩子条目:
// position, file, function
$hook_array['process_record'] = Array();
$hook_array['process_record'][] = Array(1, 'Conditional formatting in a listview column', 'custom/modules/Leads/ListViewLogicHook.php','ListViewLogicHook','getListValue');
最后,在您的 listviewdefs 添加新列:
'MY_LISTVIEW_VALUE_C' =>
array (
'width' => '10%',
'label' => 'LBL_MY_LISTVIEW_VALUE_C',
'default' => true,
),
希望有帮助。