手动在phpgrid中添加静态列

Add static column in phpgrid manually

使用phpgrid.com 创建数据网格。现在我想为所有行添加一个名为 XYZ 的列,内容为 ABC。可能吗?所有行的内容都是静态的,根本不会改变。该列不是从 mysql table.

中提取的

您需要使用虚拟列add_column

http://phpgrid.com/example/virtual-column-aka-calculated-column/

$col_formatter = <<<COLFORMATTER
function(cellvalue, options, rowObject){    
    return "ABC";
}
COLFORMATTER;

$dg -> add_column(
        'XYZ', 
        array('name'=>'XYZ', 
            'index'=>'XYZ', 
            'width'=>'360', 
            'align'=>'left', 
            'sortable'=>false,
            'formatter'=>$col_formatter),
        'XYZ');