简体   繁体   中英

Add static column in phpgrid manually

Using phpgrid.com to create a datagrid. Now i want to add a column named XYZ and with contents as ABC for all rows. Is it possible? The content is static for all rows and wont change at all. The column is not fetched from mysql table.

You need to use virtual column 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');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM