Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    ListGrid with non-editable summary row

    Be sure your post includes:

    1. v8.1p_2013-05-14/PowerEdition Deployment (built 2013-05-14)

    2. Firefox 21.0

    Is there a way to create a ListGrid with editable fields but non-editable summary row for these fields using setShowGridSummary/setShowGroupSummary?

    Thanks,

    Cristian

    #2
    Hi Cristian,
    By default both the group and grid summary rows are non-editable in a ListGrid showing these summaries.
    Can you show us a test case that demonstrates the summary rows being editable?

    Also - we notice you're on an 8.1 branch version of SmartClient (which is the base for SmartGWT 2.5). Is upgrading to a more recent branch/build an option for you?

    Regards
    Isomorphic Software

    Comment


      #3
      Hello,

      I am doing a setCanEdit() on the column. By making the column editable the summary for the that column becomes editable too. I tried to use, inside canEditCell(), a record.getIsGridSummary() or record.getIsGroupSummary() to identify the summary row and make the cell non-editable but it appears that canEditCell() is not called for summary rows (see the code below, IpListGrid extends ListGrid).

      poLinesGrid = new IpListGrid("PoItemCanvas.PoLinesGrid") {
      @Override
      protected boolean canEditCell(int rowNum, int colNum) {
      // Get the grid record for this row and the field name for
      // the column
      ListGridRecord record = this.getRecord(rowNum);
      ListGridField field = this.getFields()[colNum];
      if (record.getIsGridSummary())
      return false;
      return canEditPoLines(field, record);
      }
      I have also found this post http://forums.smartclient.com/showthread.php?t=27707 which seems to confirm that this was a bug that was recently resolved, unfortunately we cannot upgrade, at least not right now.

      Thanks,

      Cristian
      Last edited by cpopescu; 10 Oct 2013, 18:34.

      Comment


        #4
        You're right - there was an issue here which has been resolved in more recent branches.

        We are not actively backporting fixes all the way back to this branch in general but will make an exception for this case as the fix is very small. As of the next nightly build you should no longer be able to edit grid-summary rows where "canEdit" is explicitly set to true for the field.

        Regards
        Isomorphic Software

        Comment


          #5
          ListGrid with non-editable summary row

          Appreciate the help! Cristian

          Comment


            #6
            ListGrid with non-editable summary row

            Hello,

            Thanks again for backporting the fix for us. The new build did fix the issue with the editable summary row, but it also seems to have changed the behavior for the formula columns. In the past it would perform the formula on the totals, while now it performs the formula on each row and then adds all the rows values to compute the summary. For instance we have a database containing this field:
            <field name="margin" title="Margin" type="percentage" canEdit="false" width="75" customSQL="true" detail="true">
            <userFormula text="1-(C/R)">
            <formulaVars>
            <C>costScheduled</C>
            <R>retailScheduled</R>
            </formulaVars>
            </userFormula>
            </field>
            We have two items : A with C=4 and R=10 resulting in a margin of 60 % and B with C=6 and R=10 resulting in a margin of 40%. With the previous build the percentage summary came at 50% (correct) while with the new it comes at 100%.

            Thanks,

            Cristian

            Comment


              #7
              Which build are you seeing that behavior on?
              If you're looking at 4.0p [AKA SmartClient 9.0p], try the
              applyFormulaAfterSummary property.
              (This property was not added to the 8.3 / 3.1 branch, so if you're seeing this behavior there, it must be something else going on)

              Regards
              Isomorphic Software

              Comment


                #8
                ListGrid with non-editable summary row

                Sorry, forgot to mention we just upgraded to SmartGWT 4.1d PowerEdition 2013-10-17 (v9.1d_2013-10-17/PowerEdition Deployment (built 2013-10-17)).

                Thanks,

                Cristian

                Comment


                  #9
                  Thanks. Have you looked at the applyFormulaAfterSummary property previously mentioned? Does it solve your issue?

                  Comment


                    #10
                    ListGrid with non-editable summary row

                    I did try it, but it doesn't appear to make a difference. It is still applying the formula to each row and then summarizes the rows.
                    deliveryGrid.setShowAllRecords(true);
                    deliveryGrid.setShowGridSummary(true);
                    deliveryGrid.setApplyFormulaAfterSummary(true);
                    deliveryGrid.setUseAllDataSourceFields(true);

                    I can use a "SummaryFunction" for the field, but the issue is that now I have to find all the formula fields in all the ListGrids that we are using and add a "SummaryFunction".

                    Thanks,

                    Cristian

                    Comment


                      #11
                      Hi Cristian
                      There may be some confusion here. The best way for us to make sure we're talking about exactly the same thing would be for you to put together a small standalone test case we can actually run which demonstrates the problem as well as a description of what you're seeing, vs what you're expecting to see.

                      It should be fairly quick and easy to put together such a test case - simply create a new EntryPoint class, and have your onModuleLoad method build a simple ListGrid which has settings to match the problem. For DataSources, you can use clientOnly dataSources to make them small and standalone (or show us your .ds.xml file, plus a sample fetch response so we have some test data to work with).

                      With such a test case we can actually see exactly what you're seeing and be sure to address the problem properly.

                      Regards
                      Isomorphic Software

                      Comment


                        #12
                        ListGrid with non-editable summary row

                        Hello,

                        I have attached the .java files for the test case app and here's the formula field ("margin") in the ds.xml file:

                        <field name="costScheduled" title="Delivery Cost Value" type="wholeCurrency"
                        canEdit="false" detail="true"
                        customSelectExpression="(select sum(unitsOrd*homeLCP) from ProductionDestination where ProductionDestination.parentId = ProductionDelivery.id)">
                        <!--
                        The total landed cost value of all destination orders related to the delivery,
                        expressed in the currency for the Buying Office Zone with which this order
                        is associated. It is calculated as the sum of unitsOrd*homeLCP from all related
                        ProductionDestination records.
                        -->
                        </field>
                        <field name="retailScheduled" title="Delivery Retail Value" type="wholeCurrency"
                        canEdit="false" detail="true"
                        customSelectExpression="(select sum(unitsOrd*homeRetail) from ProductionDestination where ProductionDestination.parentId = ProductionDelivery.id)">
                        <!--
                        The total retail value of all destination orders related to the delivery,
                        expressed in the currency for the Buying Office Zone with which this order
                        is associated. It is calculated as the sum of unitsOrd*homeRetail from all related
                        ProductionDestination records.
                        -->
                        </field>
                        <field name="margin" title="Margin" type="percentage" canEdit="false" width="75" customSQL="true" detail="true">
                        <userFormula text="1-(C/R)">
                        <formulaVars>
                        <C>costScheduled</C>
                        <R>retailScheduled</R>
                        </formulaVars>
                        </userFormula>
                        </field>
                        <field name="markup" title="Markup" type="percentage" canEdit="false" width="75" customSQL="true" detail="true">
                        <userFormula text="(R-C)/C">
                        <formulaVars>
                        <C>costScheduled</C>
                        <R>retailScheduled</R>
                        </formulaVars>
                        </userFormula>
                        </field>

                        <field name="unitsReceived" title="Units Received" type="integer" canFilter="true"
                        canEdit="false" detail="true">
                        <!-- The sum of units received for all related destinations. -->
                        <customSelectExpression>
                        (select sum(ITQR*IPKQTY)
                        from IPPOITM where IONO in
                        (select ProductionDestination.controlNum from ProductionDestination
                        where ProductionDestination.parentId = ProductionDelivery.id))
                        </customSelectExpression>
                        </field>

                        I could not make use of a .ds.xml file in the application.

                        Thanks,

                        Cristian
                        Attached Files

                        Comment


                          #13
                          Hi Cristian,

                          examining your code we can see that you are using listGrid.setApplyFormulaAfterSummary(true) to specify that all the formulas should be executed for the summary fields. But, as stated in the javadoc for ListGrid.setApplyFormulaAfterSummary, this value, "May be overridden at the field level via applyAfterSummary". Although it is not included in the example code that you provided, to specify that the margin field should be displayed in the grid there should be something similar to this line:

                          ListGridField margin = new ListGridField("margin");

                          The problem is that, by default, ListGridField objects have the applyAfterSummary flag set to FALSE. This is why, as this value in the ListGridField overrides the value set for the ListGrid, this field is not applying the formula to the summary value.

                          We are working on getting rid of the requirement to explicitly specify this in the future, and we'll update the thread to let him know when that is done.

                          In the mean time, as a simple work around, you just need to add this line after the declaration of the "margin" ListGridField:
                          margin.setApplyAfterSummary(true);

                          So, your Sizing.java file should end looking like this:

                          ...

                          ListGridField margin = new ListGridField("margin");
                          margin.setApplyAfterSummary(true);

                          listGrid.setFields(orderNumber, itemsCost, itemsRetail, marginPercent, margin);

                          listGrid.draw();
                          }
                          }

                          One more thing, to test your code without the need to setup a database, we changed the definition of "margin" field to this one:

                          <field name="margin" title="Margin" type="float" canEdit="false" width="75" customSQL="true" >
                          <userFormula text="1-(C/R)">
                          <formulaVars>
                          <C>itemsCost</C>
                          <R>itemsRetail</R>
                          </formulaVars>
                          </userFormula>
                          </field>

                          Regards
                          Isomorphic Software

                          Comment


                            #14
                            Prior to introducing this new api the default behavior was as if you had specified setApplyFormulaAfterSummary(true). Could that be made the default behavior again so that formulas continue to work as they had before unless we decide to use the new api?

                            Comment

                            Working...
                            X