View Poll Results: Was this helpful?

Voters
325. You may not vote on this poll
  • Yes - Very Much

    250 76.92%
  • Yes - Had to tweak it

    45 13.85%
  • No - Maybe

    14 4.31%
  • Not at All!!!

    16 4.92%
  1. #461
    Sencha User
    Join Date
    Apr 2011
    Posts
    2
    Vote Rating
    0
    bhuskey is on a distinguished road

      0  

    Default How to exclude a row from the total?

    How to exclude a row from the total?


    Hi Everyone,

    I can't for the life of me figure out how to exclude a row from being totaled in the summary row (I'm using summaryType: 'sum').

    My setup is this: a 4 column editor grid with 8 rows (happens to be fixed number of rows). 3 of the 4 columns are summaryType: 'sum'. I want to exclude 1 specific row from the sum. My grid currently looks like this:

    Row1: 5 10 12
    Row2: 0 0 5
    Row3: 2 13 0

    Total: 7 23 17

    I want it to look like this (exclude a row, say Row3):

    Row1: 5 10 12
    Row2: 0 0 5
    Row3: 2 13 0

    Total: 5 10 17

    If someone can point me in the right direction, I think I can figure it out. What should I be doing and where should the code go? I've been trying to modify my column's summaryRenderer...

    summaryRenderer: function(value, meta, record, rowIndex, colIndex, store) {
    console.log('new renderer>record...', value, meta, record, rowIndex, colIndex, store);
    }

    rowIndex, colIndex, store are all undefined! I was going to use rowIndex to get the row then subtract its values from value.

    I'm using Ext 3.3.1 and here's some of my code:

    function InterventionAreaGroupLandUse() {
    return this;
    }


    InterventionAreaGroupLandUse.dataGrid = null;


    InterventionAreaGroupLandUse.save = function() {
    InterventionAreaGroupLandUse.dataGrid.commitChanges();
    };


    InterventionAreaGroupLandUse.init = function() {


    function areaRendererTest(value, meta, record, rowIndex, colIndex, store) {
    console.log('new renderer>record...', value, meta, record, rowIndex, colIndex, store);
    }


    function areaRenderer(data, params, v) {
    if (v != null) {
    if (v == 0) {
    return '<span style="color: red">' + v + '</span>';
    }
    else {
    return (v <= Ext.num(InterventionAreaGroupList.getSelectedGroupArea(), 1)) ? ('<span style="color: green">' + v + '</span>') : ('<span style="color: red">' + v + '</span>');
    }
    }
    else {
    return '';
    }
    }


    var cm = new Ext.grid.ColumnModel({
    defaults: {
    sortable: true,
    menuDisabled: true
    },
    columns: [
    {
    header: 'Land Use Category',
    dataIndex: 'LandUseCategory',
    width: 150,
    editable: false,
    renderer: function(value) {
    return value.Name;
    },
    summaryRenderer: function(v, params, data) {
    return 'Total Area (ha)*';
    }
    },
    new Ext.grid.NumberColumn({
    header: 'Initial Land Use',
    dataIndex: 'InitialArea',
    format: '0',
    width: 150,
    editor: new Ext.form.NumberField({
    allowBlank: false,
    allowDecimals: false
    }),
    summaryType: 'sum',
    summaryRenderer: areaRenderer
    }),
    new Ext.grid.NumberColumn({
    header: 'Baseline Scenario',
    dataIndex: 'BaselineArea',
    format: '0',
    width: 150,
    editor: new Ext.form.NumberField({
    allowBlank: false,
    allowDecimals: false
    }),
    summaryType: 'sum',
    summaryRenderer: function(value, meta, record, rowIndex, colIndex, store) {
    console.log('new renderer>record...', value, meta, record, rowIndex, colIndex, store);
    }
    }),
    new Ext.grid.NumberColumn({
    header: 'Project Scenario',
    dataIndex: 'ProjectArea',
    format: '0',
    width: 150,
    editor: new Ext.form.NumberField({
    allowBlank: false,
    allowDecimals: false
    }),
    summaryType: 'sum',
    summaryRenderer: areaRenderer
    })
    ]
    });


    InterventionAreaGroupLandUse.dataGrid = new CbpGrid();


    var summaryPlugin = new Ext.ux.grid.GridSummary();


    InterventionAreaGroupLandUse.dataGrid.deletable = false;
    InterventionAreaGroupLandUse.dataGrid.updateStatus = false;


    InterventionAreaGroupLandUse.dataGrid.listUrl = Cbp.baseUrl + 'InterventionAreaGroupLandUse/List?groupId=' + InterventionAreaGroupList.getSelectedValue();
    InterventionAreaGroupLandUse.dataGrid.updateUrl = Cbp.baseUrl + 'InterventionAreaGroupLandUse/Update?groupId=' + InterventionAreaGroupList.getSelectedValue();
    InterventionAreaGroupLandUse.dataGrid.height = 250;
    InterventionAreaGroupLandUse.dataGrid.columnPlugins = [summaryPlugin];
    InterventionAreaGroupLandUse.dataGrid.columnModel = cm;
    InterventionAreaGroupLandUse.dataGrid.dataFields = [
    { name: 'Id' },
    { name: 'LandUseCategory', mapping: 'LandUseCategory' },
    { name: 'InitialArea', type: 'int' },
    { name: 'BaselineArea', type: 'int' },
    { name: 'ProjectArea', type: 'int' },
    { name: 'LandUseCategoryId', mapping: 'LandUseCategory.Id', type: 'int'}];


    InterventionAreaGroupLandUse.dataGrid.renderTo = 'editorGrid';


    InterventionAreaGroupLandUse.dataGrid.init();
    };

    Let me know if more information is needed! Thanks a lot for any help.

  2. #462
    Sencha User
    Join Date
    Apr 2011
    Posts
    2
    Vote Rating
    0
    bhuskey is on a distinguished road

      0  

    Default I fixed it!

    I fixed it!


    Never mind, I figured it out!

    I added a new calculation to Ext.ux.grid.GridSummary.Calculations:

    Ext.ux.grid.GridSummary.Calculations['sumExcludeLivestock'] = function(v, record, colName, data, rowIdx) {
    if (record.data.LandUseCategory.Id === 8) {
    return (data[colName] + Ext.num(v, 0)) - Ext.num(v, 0);
    }
    else {
    return data[colName] + Ext.num(v, 0);
    }
    };

    then I changed the summaryType of the columns from 'sum' to this new calculation, 'sumExcludeLivestock'.

  3. #463
    Sencha Premium Member Troy Wolf's Avatar
    Join Date
    May 2007
    Location
    Kansas City
    Posts
    251
    Vote Rating
    2
    Troy Wolf is on a distinguished road

      0  

    Default


    Big thanks to MaxT for showing me how to enable a different scope within the summary renderer handlers.
    http://www.sencha.com/forum/showthre...l=1#post254649.

    Standard cell renderers are affected by "scope: this", but summaryRenderer is not unfortunately. MaxT's fix showed me how to get a reference to something beyond the event itself.

  4. #464
    Sencha User
    Join Date
    Mar 2010
    Posts
    30
    Vote Rating
    1
    eurobax is on a distinguished road

      0  

    Default


    Hi! What is your progress in such significant work for Ext 4?
    I suppose, this feature should be configurable - showing summary either in top or at bottom of grid.
    I'll be very lickely if there is a solution, as I've dissapointed in standart feature, which is very-very useless.
    Quote Originally Posted by cnesbit View Post
    +1
    I've begun a (very simple) extjs 4.0 version, if anyone cares to take it and run with it. The only major hangup I've come across so far is the width of the cells in the fixed summary row, they seem to not line up with the cell widths of my grid.
    ....
    Feedback, constructive criticism, or suggested improvements would be appreciated.

  5. #465
    Sencha User
    Join Date
    Nov 2011
    Location
    Singapore
    Posts
    8
    Vote Rating
    0
    anuruddha84 is on a distinguished road

      0  

    Default


    Quote Originally Posted by eliezerreis View Post
    I did some upgrades in Ext.ux.grid.GridSummary plugin.
    Now you can use it with Simple Grid and with Grouped Grid. If you use it with Group Grid you have summary for groups and for all grid (In the footer).

    I put the sample with source code on http://www.snews.com.br/eliezer/gridsummary/
    I dont know if is a better way to do this, but in my case worked fine. mystix you can see my code and look with you can use it on your plugin.

    If anyone find some bug or make another upgrade, keep us informed!!
    Hi mystix , eliezerreis
    I don't have words for Thanking you 2 guys. This is what I really want.

  6. #466
    Sencha User
    Join Date
    Apr 2012
    Posts
    15
    Vote Rating
    1
    Mcaveti is on a distinguished road

      1  

    Default Grouping Summary with Total Row for Ext 4.0.7

    Grouping Summary with Total Row for Ext 4.0.7


    Dear friends!
    I did extension to the 4 version of the Ext for the Grouping Summary. Look here http://www.sencha.com/forum/showthre...478#post790478
    I would be very grateful for your comments and additions

  7. #467
    Sencha User
    Join Date
    May 2011
    Posts
    4
    Vote Rating
    1
    jimprotos is on a distinguished road

      1  

    Default Fixedsummary : a different approach

    Fixedsummary : a different approach


    If you are interested in checking a slightly different approach, try the fixedsummary grid feature a friend of mine and I have implemented.

    Code available at:
    https://github.com/geovar89/FixedSummary

    Demo available at:
    http://geovar89.github.io/FixedSummary/

    (checked against Ext JS 4.1 and Ext JS 4.2 on major browsers)

    The implementation idea is based on docking a one-row summary grid to our basic grid, and listening to the basic grid column events to simulate a compact component behaviour. It also introduces the idea of displaying all standard aggregate values (count, sum, min, max, average) when hovering over the column header.

    We will be glad to be getting some feedback from you (as it is our first project published as open source) along with whatever bugs, remarks or requests you might come up with.

    We hope our feature might be of some help, like we have been helped numerous times by similar posts...
    Attached Images

  8. #468
    Sencha User
    Join Date
    Jan 2014
    Location
    pittsburg , PA
    Posts
    32
    Vote Rating
    0
    arunmatics is on a distinguished road

      0  

    Default


    Hi,
    in my ExtJs 2.3 i cant find gridsummary in Ext.Grid.

    How can i add the gridesummary in Ext.Grid. where i need to put the code ? please help me.

    Thanks,
    Santhosh

Thread Participants: 132

  1. franklt69 (3 Posts)
  2. Condor (18 Posts)
  3. mapo (3 Posts)
  4. HarryC (1 Post)
  5. mystix (139 Posts)
  6. jared (1 Post)
  7. MaxT (1 Post)
  8. wayne_o (2 Posts)
  9. soreport (1 Post)
  10. violinista (1 Post)
  11. bloon (1 Post)
  12. Troy Wolf (1 Post)
  13. tobiu (1 Post)
  14. Deleter (3 Posts)
  15. sintax.era (2 Posts)
  16. chernomorez (1 Post)
  17. lychorojostone (2 Posts)
  18. 6epcepk (6 Posts)
  19. zaunaf (1 Post)
  20. SlashEMc2k (1 Post)
  21. americos (1 Post)
  22. Layne (1 Post)
  23. jamie.nicholson (1 Post)
  24. mscdex (1 Post)
  25. vnug (2 Posts)
  26. dima (3 Posts)
  27. froamer (3 Posts)
  28. mondomon (3 Posts)
  29. kenshin (1 Post)
  30. rtconner (2 Posts)
  31. juljupy (6 Posts)
  32. lukas.wappler (4 Posts)
  33. crpatrick (1 Post)
  34. saJoshua (7 Posts)
  35. crxtech (1 Post)
  36. vertigoMX (5 Posts)
  37. sayanb (3 Posts)
  38. graveyardfashions (2 Posts)
  39. mwh154 (1 Post)
  40. calavera (2 Posts)
  41. JasonOng (1 Post)
  42. httpdotcom (5 Posts)
  43. kimosabi (2 Posts)
  44. uygarpe (1 Post)
  45. csextjs (2 Posts)
  46. Richie1985 (7 Posts)
  47. eliezerreis (5 Posts)
  48. dado.cubo (1 Post)
  49. Rafael (16 Posts)
  50. chrissturm (2 Posts)
  51. thomasf (1 Post)
  52. Rainher (1 Post)
  53. timotti (2 Posts)
  54. hongfu (1 Post)
  55. rnfbr1 (2 Posts)
  56. issameddine (2 Posts)
  57. rums (4 Posts)
  58. nuser (6 Posts)
  59. mntek (2 Posts)
  60. MichaelOstrovsky (1 Post)
  61. anghuda (1 Post)
  62. longfeisoft (2 Posts)
  63. nameroc (1 Post)
  64. georgeblackjr (1 Post)
  65. vinnybozz (2 Posts)
  66. mcouillard (2 Posts)
  67. wwwtd (5 Posts)
  68. s4brown (2 Posts)
  69. Shmitt (12 Posts)
  70. CEBEP (1 Post)
  71. charleshimmer (7 Posts)
  72. ondra.cz (1 Post)
  73. Eisstern (3 Posts)
  74. rasto1968 (2 Posts)
  75. hpandey (1 Post)
  76. xpete (1 Post)
  77. pratapbm (1 Post)
  78. leonardb (2 Posts)
  79. Trinad (2 Posts)
  80. larkworm (1 Post)
  81. bobjbain (1 Post)
  82. NetFantom (1 Post)
  83. amini (2 Posts)
  84. quen567 (2 Posts)
  85. pieter333 (1 Post)
  86. creepi (1 Post)
  87. ekhanh101 (4 Posts)
  88. alexbanda1982 (1 Post)
  89. damon1977 (1 Post)
  90. pablosn (2 Posts)
  91. cnesbit (1 Post)
  92. uniring (2 Posts)
  93. Jim.Barrows (1 Post)
  94. y_joren3 (2 Posts)
  95. ranadheersingh (2 Posts)
  96. quicksilver_in (2 Posts)
  97. Bleak (1 Post)
  98. janasri (1 Post)
  99. agfk (4 Posts)
  100. mcaudle28 (3 Posts)
  101. msinn (2 Posts)
  102. madirishman (2 Posts)
  103. blackghost (6 Posts)
  104. zvds (1 Post)
  105. sonixbp (5 Posts)
  106. tripEXITo (1 Post)
  107. erikenge (1 Post)
  108. sideview1 (1 Post)
  109. kuthz (1 Post)
  110. AfzalA (1 Post)
  111. pomuchi (1 Post)
  112. DerSalz (2 Posts)
  113. brycekmartin (2 Posts)
  114. malkandari (1 Post)
  115. eurobax (3 Posts)
  116. Fallen Zen (6 Posts)
  117. mayurid (1 Post)
  118. rOCTb (1 Post)
  119. t2nguyen (1 Post)
  120. Manivel (10 Posts)
  121. wigwam_salesman (13 Posts)
  122. ExTriqui (4 Posts)
  123. Tod (2 Posts)
  124. PavelG (1 Post)
  125. joelchu (1 Post)
  126. optiplex (1 Post)
  127. grace.lawrence (1 Post)
  128. bhuskey (2 Posts)
  129. jimprotos (1 Post)
  130. anuruddha84 (1 Post)
  131. Mcaveti (1 Post)
  132. arunmatics (1 Post)