2017-02-21 88 views
0

在phpgrid中,我使用add_column方法添加了虛擬列(不存在於db中的列)。但問題是我不能讓它出現在第一個位置(即表格的第一列)。 add_column方法的文檔說明它將被附加在其他列的末尾add_method for phpgrid。是否有可能將其添加到第一列/位置?我嘗試了各種jQuery的黑客,但似乎沒有用。更改虛擬列的位置phpgrid

下面是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; 
    } 

回答

1

最後一個參數指示列位置。

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

這應該將虛擬列置於索引0的第一列。

+0

非常感謝。它的工作原理 –

+0

歡迎您! – user3915432

+0

列出現在第一個位置,但其他列中的數據混亂了,在表頭中,我可以看到列的標題,但無法看到表中的數據。 –