在phpgrid中手动添加静态列


Add static column in phpgrid manually

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

您需要使用虚拟列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');