Guest User

Untitled

a guest
Jan 21st, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. SELECT SUM(precio) AS totalprecio FROM productos
  2.  
  3. <?= yiigridGridView::widget([
  4. 'dataProvider' => $dataProvider,
  5. 'showFooter' => true,
  6. 'columns' => [
  7. ['attribute' => 'precio',
  8. 'footer' => sumarizeFooter( $dataProvider->getModels() ),
  9. 'format' => 'raw',
  10. ],
  11. ]
  12. ]) ?>
  13.  
  14. function sumarizeFooter($model){
  15. $iSum = 0;
  16. foreach ($model as $obj){
  17. $iSum += floatval($obj->precio);
  18. }
  19. return $iSum;
  20. }
Add Comment
Please, Sign In to add comment