Summary cells

26 views
Skip to first unread message

Dmitry Klimkin

unread,
Dec 20, 2012, 10:32:16 PM12/20/12
to koala-fra...@googlegroups.com
Is it possible to add summary row into the grid?

Niko Sams

unread,
Dec 21, 2012, 1:44:51 PM12/21/12
to koala-fra...@googlegroups.com
yes.

what koala autogrid does for you is to configure a grid with a store
and columns. You then can work with
it as ExtJS grid.

most stuff you can configure by setting gridConfigfor example like this:
new Kwf.Auto.GridPanel({
controllerUrl: '...',
gridConfig: {
plugins: summary
}
})

the grouping store you can configure by setting protected $_grouping in Php:
$_grouping = array(
'groupField' => 'foo'
);


Niko

Dmitry Klimkin

unread,
Dec 21, 2012, 7:15:34 PM12/21/12
to koala-fra...@googlegroups.com
Thanks!

Dmitry Klimkin

unread,
Dec 22, 2012, 9:11:42 AM12/22/12
to koala-fra...@googlegroups.com
Still can't make it work... Is this way correct ? :

        var summary = new Ext.grid.GroupSummary();

        var flightresults = new Kwf.Auto.GridPanel({

              controllerUrl   : '/flightresults',

              region          : 'south',

              height          : 200,

              resizable       : true,

              split           : true,

              collapsible     : true,

              gridConfig      : {

                                    plugins: summary

                                },

              title           : trlKwf('Flight results')

        });

Dmitry Klimkin

unread,
Dec 22, 2012, 11:46:09 AM12/22/12
to koala-fra...@googlegroups.com
Even more... If I add 

    #protected $_grouping = array('groupField' => 'typeId');

to the controller class app hangs on loading...

Niko Sams

unread,
Dec 22, 2012, 12:56:36 PM12/22/12
to koala-fra...@googlegroups.com
On Sat, Dec 22, 2012 at 5:46 PM, Dmitry Klimkin
<dmitry....@gmail.com> wrote:
> Even more... If I add
>
> #protected $_grouping = array('groupField' => 'typeId');
>
> to the controller class app hangs on loading...
>
hangs on loading = javascript error.

open FireBug to get details about it.

in this case ExtGroupingGrid dependency is missing I guess.

Niko

Niko Sams

unread,
Dec 22, 2012, 12:59:28 PM12/22/12
to koala-fra...@googlegroups.com
On Sat, Dec 22, 2012 at 3:11 PM, Dmitry Klimkin
<dmitry....@gmail.com> wrote:
> Still can't make it work... Is this way correct ? :
>
> var summary = new Ext.grid.GroupSummary();
>
> var flightresults = new Kwf.Auto.GridPanel({
>
> controllerUrl : '/flightresults',
>
> region : 'south',
>
> height : 200,
>
> resizable : true,
>
> split : true,
>
> collapsible : true,
>
> gridConfig : {
>
> plugins: summary
>
> },
>
> title : trlKwf('Flight results')
>
> });
>
the summary settings are missing, you can add it using:
columnsConfig: {
colname: {
summaryType: 'count',
summaryRenderer: function(v, params, data) { ... }
}
}

other missing things you probably see as JS errors in FireBug.

Dmitry Klimkin

unread,
Dec 22, 2012, 7:53:13 PM12/22/12
to koala-fra...@googlegroups.com
yes, adding a dependency helped a bit...
but now i see an js exception text:

  1. Uncaught TypeError: Object [object Object] has no method 'each' Admin.js:30129
    1. Kwf.Auto.GridPanel.Ext.extend.onMetaLoadAdmin.js:30129
    2. metaConn.request.successAdmin.js:30833
    3. Kwf.Connection.Ext.extend.kwfJsonSuccessAdmin.js:24808
    4. Ext.apply.callbackAdmin.js:289
    5. Ext.extend.handleResponseAdmin.js:24369
    6. Ext.lib.Ajax.handleTransactionResponseAdmin.js:1307
    7. (anonymous function)

and a part of my controller.js:

        var summary = new Ext.grid.GroupSummary();

        var results = new Kwf.Auto.GridPanel({

              controllerUrl   : '/results',

              region          : 'south',

              height          : 200,

              resizable       : true,

              split           : true,

              collapsible     : true,

              gridConfig      : {

                                    plugins: summary

                                },

              columnsConfig: {

                        colname: {

                            summaryType: 'sum',

                                summaryRenderer: function(v)

                                                   {

                                                       return v;

                                                   } 

                                }

                            },

              title           : trl('Results')

        });

Dmitry Klimkin

unread,
Dec 22, 2012, 10:08:29 PM12/22/12
to koala-fra...@googlegroups.com
I found a pretty solution:

1. add following into Kwf_Grid_Column

    public function setSummaryType($summaryType)

    {

        $ret = $this->setProperty('summaryType', $summaryType);

        return $ret;

    }

    

    public function setSummaryRenderer($rendererType)

    {

        $ret = $this->setProperty('summaryRenderer', $rendererType);

        return $ret;

    }

2. In custom controller php class define as following:

    protected $_grouping = array('groupField' => 'planeName');

    protected function _initColumns()

    {

        $this->_filters = array('text' => array('type' => 'TextField'));

        $this->_columns->add(new Kwf_Grid_Column('resultTime', trl('Time')))

        ->setSummaryType('totalTime');

    }

3. In the corresponding js add following:

// define a custom summary function

Ext.grid.GroupSummary.Calculations['resultTime'] = function(v, record, field)

{

    return //some calculation

}

4. And following into dependencies:

Admin.dep[] = ExtGroupingGrid

Admin.dep[] = ExtGridSummary


Thanks.

Dmitry Klimkin

unread,
Dec 22, 2012, 10:10:06 PM12/22/12
to koala-fra...@googlegroups.com
Could you please include related described changes of the Kwf_Grid_Column include into you master branch?

Thank you.

Niko Sams

unread,
Dec 23, 2012, 4:36:21 AM12/23/12
to koala-fra...@googlegroups.com
On Sun, Dec 23, 2012 at 1:53 AM, Dmitry Klimkin
<dmitry....@gmail.com> wrote:
>
> columnsConfig: {
> colname: {
> summaryType: 'sum',
> summaryRenderer: function(v)
> {
> return v;
> }
> }
> },
"colname" should be the name of your column, one entry per column :D

Niko Sams

unread,
Dec 23, 2012, 4:39:30 AM12/23/12
to koala-fra...@googlegroups.com
On Sun, Dec 23, 2012 at 4:08 AM, Dmitry Klimkin
<dmitry....@gmail.com> wrote:
> I found a pretty solution:
good! yes that's also possible - instead of defining columnConfig in JS.
(the only downside is that you can't define a function in Php as you
could in JS)

>
> 1. add following into Kwf_Grid_Column
>
> public function setSummaryType($summaryType)
> {
> $ret = $this->setProperty('summaryType', $summaryType);
> return $ret;
> }
>
> public function setSummaryRenderer($rendererType)
> {
> $ret = $this->setProperty('summaryRenderer', $rendererType);
> return $ret;
> }
you don't have to do that. The __call method does that automatically. (it takes
all set* calls and sets the property.)

Niko

Niko Sams

unread,
Dec 23, 2012, 4:40:12 AM12/23/12
to koala-fra...@googlegroups.com
On Sun, Dec 23, 2012 at 4:10 AM, Dmitry Klimkin
<dmitry....@gmail.com> wrote:
> Could you please include related described changes of the Kwf_Grid_Column
> include into you master branch?
as I've writte in the other mail you don't need that - it will still
work correctly.
Can you confirm that?

Niko

Dmitry Klimkin

unread,
Dec 23, 2012, 4:49:19 AM12/23/12
to koala-fra...@googlegroups.com
Sure, I tried to use setProperty and it works fine too. The only one thing I decided to implement it in the controller is just I don't want to specify column name in js. 

Niko Sams

unread,
Dec 23, 2012, 5:32:05 AM12/23/12
to koala-fra...@googlegroups.com
On Sun, Dec 23, 2012 at 10:49 AM, Dmitry Klimkin
<dmitry....@gmail.com> wrote:
> Sure, I tried to use setProperty and it works fine too.
yes, but using setSummaryType() should also work *without* the patch.

> The only one thing I
> decided to implement it in the controller is just I don't want to specify
> column name in js.
yes, I would also prefer Php. I didn't know it can be done that way :D

Niko

Artyom M

unread,
Dec 22, 2014, 12:07:34 AM12/22/14
to koala-fra...@googlegroups.com
Niko,

I want to add some text under the fields. I do this in following way:

1)in controller:
$this->_columns->add(new Kwf_Grid_Column('ownerName', 'ФИО'))->setProperty('summaryType', 'totalName')->setWidth(150);

2)in js:
Ext2.grid.GroupSummary.Calculations['totalName'] = function(v, record, field) {
    return 'Итого: '
}

but app shows error:
TypeError: Ext2.grid.GroupSummary.Calculations[cf.summaryType] is not a function


In other controller all works well and if I put name of other controller function - it works.

Niko Sams

unread,
Dec 24, 2014, 6:59:58 AM12/24/14
to Koala Framework Dev
do some javascript debugging and check cf.summaryType and Ext2.grid.GroupSummary.Calculations

if you break on errors in your javascript debugger you can inspect the values...

Niko

--
You received this message because you are subscribed to the Google Groups "Koala Framework Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to koala-framework...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Artyom M

unread,
Jan 21, 2015, 1:32:07 AM1/21/15
to koala-fra...@googlegroups.com
I don't know what happened, but now the same code working perfect =)
Reply all
Reply to author
Forward
0 new messages