【问题标题】:Changing the position of virtual column phpgrid改变虚拟列phpgrid的位置
【发布时间】:2017-07-11 04:06:21
【问题描述】:

在 phpgrid 中,我使用 add_column 方法添加了一个虚拟列(db 中不存在该列)。但问题是我不能让它出现在第一个位置(即表格的第一列)。 add_column 方法的文档说它将附加在其他列的末尾add_method for phpgrid。是否可以将其添加到第一列/位置?我尝试了各种 jquery hack,但似乎没有一个有用。

下面是add_column的代码

PHP 代码

$dg->add_column("custom", array('name'          => 'custom',
                                'index'         => 'custom',
                                'width'         => '100',
                                'formatter'     => '###customAction###',
                                'formatoptions' => array('keys' => true, 'editbutton' => true, 'delbutton' => true)), 'Custom Action');

JAVASCRIPT 代码

function customAction(cellValue, options, rowdata) {
        output = '<span class="custom-action"><i class="glyphicon glyphicon-plus custom" data-transaction-id="' + options.rowId + '"></i></span>';
        return output;
    }

【问题讨论】:

    标签: javascript php jquery jqgrid phpgrid


    【解决方案1】:

    最后一个参数表示列位置。

    $dg->add_column('total', array('name'=>'total', 'index'=>'total', 'width'=>'100', 'align'=>'right', 'sortable'=>false,
        'formatter'=>$col_formatter),
            'Total (Virtual)', 0);
    

    这应该把虚拟列放到索引0,第一列。

    【讨论】:

    • 列排在第一位但是其他列的数据乱了,在表头我可以看到列的标题但是看不到表中的数据。
    猜你喜欢
    • 2017-07-13
    • 1970-01-01
    • 2012-05-17
    • 1970-01-01
    • 1970-01-01
    • 2020-02-12
    • 1970-01-01
    • 1970-01-01
    • 2017-09-03
    相关资源
    最近更新 更多