Announcement

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

    Is there a way to getGridSummary on databound including unsaved edits?

    If you have databound grid + showGridSummary:true + waitForSave: true, autoSaveEdits: false, the summary only updates after the primaryKey is populated i guess after save operation..

    Is there a way to simply just get a summary of field(s) of all unedited (original) and any edited records?

    Sure, save locally and setData works out ok, but you loose the paging functionality of the grid..

    #2
    See the ListGrid Editing Overview and note the distinction between getRecord() and getEditedRecord().

    Comment


      #3
      so basically to get a simple sum of what is being shown on the screen, whether there are row updates, row adds etc..etc.. on a databound grid, i am having to loop all records, check if it has been edited if so get the edited record and if not getRecord, somewhere in the roweditorexit method? And switch off the gridSummaries?

      is there no simple method that'll just give me an object containing everything that is currently in the grid, in it's, "to be", if i clicked save, state...... (basically as i can and users can see it on the screen)

      Just seems more normal to have a running total running, rather than not running until i click save and even then not running if there are row errors, basically if a user is editing the grid and has 3 rows (validated or not) it is those 3 rows which are intended to be saved and hence a running total of said rows seems logical...

      I'll look at putting together a getGridSummaryOfRecordsAsTheyAreInTheGrid() type method to provide this for me... Can i do this with LGPL license? need to investigate the coding effort between that and local cache i guess

      Comment


        #4
        Sorry, we may not understand what you're getting at, but a "single object" containing all the edits in the grid doesn't make much sense - each record has edits, so at minimum a "single object" would be a structure mapping primary keys to the original records and edits..

        Comment


          #5
          ok i might also be missing something too... here's what i'm talking about...

          Example

          i have a grid with description field and value field, databound to some table, when the screen loads let's say it loads 3 records as follows

          1. ABC 10
          2. BCD 20
          3 EFG 30

          As it was from the datasource, if i edit the field value for say record 2 and change to 30 the getGridummary would return 10 + 30 + 30 = 70. However if i also added record 4

          4. HIJ 20

          the getGridSummary returns 70 still, as the added record is not recognized by getGridSummary. however to a user there is actually 10 + 30 + 30 + 20 = 90.

          After i save the record and all is well, it would then return 90 on next call to getGridSummary... (after update).

          My point is, is there a simple way to get the 90, PRESAVE... rather than post save, as if i were to add 100 records, bit painful to wait until i entered all and save, nice to see the total running along with my work.. (on the basis that i want to save them all at the end of my editing session, e..g autoSaveEdits:false)


          Hence, i was looking for a method that i could call to give me what is being presented in the grid currently. E.g. at roweditorexit getGridSummary would include any edited records (non saved yet), as if i were a user and i was happy with what i see i would click save, the 90 in my example would be what i expected to see pre and post save.

          See if i had a list of 50 items on a peice of paper with a total, i would bang away at the keys entering the data, then at the end do a totals check, if there were the same paper vs. screen i would say ok, let's save.

          Hence from your response, i guess i would need to override getGridSummary, call Super initially to get the current gridsummary for value field, then loop all edited records (that are not also part of the current mapped primary keys) e.g. new adds and sum them, add them to the return value from Super then return the result as the summary of value field for the grid as the user see's it currently (PRESAVE).

          Comment


            #6
            FYI i use PHP and REST thus no queing and master detail tables, hence i avoid a master save and save master then details, with transform request to pop the master/detail key, that key being poopulated on detail records. Hence i have autoSaveEdits as false, because the master key does not exist until i have completed editing the records master and detail. My save process is Save Header, in callback check then save lines, passing the master key to each child record via transform request.... dsRequest.data.key.... = master.key... etc..

            Comment


              #7
              You could do what you propose, or you could simply save more aggressively (on row exit).

              Or you could work with local data (provide a RecordList instead of using a DataSource). Summaries don't work with paging anyway (all data would need to be loaded in order to compute a summary).

              Comment


                #8
                ok, i'll take a look at both gridSummary override and localdata

                Comment


                  #9
                  actually here's what i'm going to do, just to make things worse... i want the totals in a separate form, as im using REST i want to set the master table totals from the entered totals of lines, thus, having been playing all day i have a solution which

                  1. grid - saveLocally, autoSaveEdits, show grid summary all true, setting the grid summary row to height of 0 (ZERO) throws warnings but just warnings i guess
                  2. override getGridSummary - set the master total fields (via values manager)
                  3. create doSAVE function that saves the master, if good, saves all lines, i check if it's an add or update using the primary key of the detail table if populated it's update if not it's add. and do the add update in a loop calling datasource.updatedata/adddata accordingly.

                  if theres a remove, i'll just remove immediately, seems fitting... again via datasource call..

                  seems to work ok, later i'll look at bulk updating sending the whole detail table over... see how the performance is... i'll wrap it up in a bow later and load it here, might be of some use for somebody later..

                  Comment


                    #10
                    Hit another problem, i found that if you set the following on a grid

                    saveLocally:true, autoSaveEdits: true, and you have a datasource assigned

                    and in any Changed(form,item,value) method, if you use item.setEditValue(item.grid.getEditRow()..... it only set's the value of the target field in the edited row, if that field is DRAWN

                    This is not normal behaviour correct? my understanding is/was that setEditValue would set a value on non drawn grid fields based upon the datasource tied to that grid. e.g i have an ID field and a NAME field, using a select item which after selection get's the selected record and pop's the ID, see below.

                    changed: function(form,item,value) {
                    var record=item.getSelectedRecord(); item.grid.setEditValue(item.grid.getEditRow(),"recharge_job_id", record.relation_job_id );
                    }

                    The above code does not save the ID on the record.. doing a grid.getEditedRecord(..) basically gives me the updated select item value but not the ID from above.

                    The only way i found it works is to do the following.

                    changed: function(form,item,value) {
                    var record=item.getSelectedRecord();
                    this.grid.getSelectedRecord().recharge_job_id=record.relation_job_id;
                    },

                    Can this be accurate?

                    Comment

                    Working...
                    X