Gridview Footer filtered Sum

Hallo!

I would like the sum of a column in Yii 2 in the filtered grid in the footer.

In Yii 1 I did this with the following function:

public function getSum () in the model {
$ search = $ this-> search ();
$ sum = 0;
foreach ($ search-> data as $ record) {
$ sum + = intval ($ record-> number);
}
return $ sum;
}

Maybe someone has an idea for this.

Thanks

To get column sum in Yii2:
$sum = SomeModel::find()->sum('columnName');

https://www.yiiframework.com/doc/api/2.0/yii-db-query#sum()-detail
Try to use it?

Thank you so much