如何使用动态名称在footerdata中设置列?

时间:2017-03-29 09:59:28

标签: jqgrid footer

如何使用动态名称在footerdata中设置列?

而不是:

$db = Zend_Registry::get('db');

$select = $db->select()
            ->from(array('air'=>$this->_name), 
                array('sumtotal' => new Zend_Db_Expr('SUM(air.price) + SUM(inst.cicilan)')));
$select->joinLeft(array('s' => 'store'), 's.id = air.store_id');
$select->joinLeft(array('ar' => 'area'), 'ar.name = s.regional');
$select->joinLeft(array('inst' => 'installment'), 'inst.sn = air.sn');
$select->where('(air.status = ?', A);
$select->orwhere('air.status = ?', B);
$select->orwhere('air.status = ?', C);
$select->orwhere('air.status = ?', D);
$select->orwhere('air.status = ?', E);
$select->orwhere('air.status = ?', F);
$select->orwhere('air.status = ?', G);
$select->orwhere('air.status = ?', H);
$select->orwhere('air.status = ?', I);
$select->orwhere('air.status = ?', J);
$select->orwhere('air.status = ?)', K);
$select->where('ar.id = ?', $area);
$select->where('CONCAT(YEAR(air.date)-MONTH(air.date)) = ?', $year . '-' . $month );
$data = $db->fetchOne($select);
return $data;

我想做点什么:

grid.footerData('set', { Total: total.toFixed(1) });

但这显然不起作用......我怎样才能做到这一点?

谢谢!

1 个答案:

答案 0 :(得分:0)

对象

{ Total: total.toFixed(1) }

拥有Total属性。您可以使用[]动态创建属性:

var colName = 'Total', options = {};
options[colName] = total.toFixed(1);
grid.footerData('set', options);