Announcement

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

    UpdateData on recordDrop

    I need to save the grid index of the record in a particular field of the record in the datasource at the time of drop.

    My code looks like:

    Code:
    isc.ListGrid.create({
        ID: "nivelEAPFisicaList",
        width: "100%",
        height: "100%",
        alternateRecordStyles: true,
        dataSource: nivelEAPFisicaDS,
        dataPageSize: 50,
        autoFetchData: true,
        canEdit: true,
        canRemoveRecords: true,
        canSort: false,
        canReorderRecords: true,
        selectionType: "single",
        fields: [
    		{ name: "NFS_NOME" },
            { name: "NFS_COR_FUNDO" },
            { name: "NFS_COR_FONTE" }
        ],
        recordDrop: function (dropRecords, targetRecord, index, sourceWidget) {        
            dropRecords[0].NFS_NIVEL = index;
            nivelEAPFisicaDS.updateData(dropRecords[0]);
            this.Super("recordDrop", arguments);
        },
        rowEditorExit: function (EditCompletionEvent, record, newValues, rowNum) {
    		if (record == null) {
    			newValues.NFS_NIVEL = rowNum;
    		}
        }
    })
    I know that the drop only organizes the records on the client and the server does not hold.

    Thus, after passing through the UpdateData, the drop is broken - the record in the grid back where it was because I think the grid to take back the order that is in the datasource after UpdateData.

    How do I get the grid with the records in the correct place after the UpdateData?

    I tried several ways but could not. I believe that a simple fetch solve the problem, but where it could fetch call this?

    SmartClient Ajax RIA system
    Version 8.0/EVAL Development Only (2011-01-21)

    Browser: IE9 e Chrome18.0.1025.168

    #2
    I tried this:

    Code:
    recordDrop: function (dropRecords, targetRecord, index, sourceWidget) {                        
                            dropRecords[0].NFS_NIVEL = index;
                            nivelEAPFisicaList.updateData(dropRecords[0], "nivelEAPFisicaList.fetchData()");                        
                        },
    Code:
    recordDrop: function (dropRecords, targetRecord, index, sourceWidget) {                        
                            dropRecords[0].NFS_NIVEL = index;
                            nivelEAPFisicaDS.updateData(dropRecords[0], "nivelEAPFisicaList.fetchData()");                        
                        },
    Code:
    recordDrop: function (dropRecords, targetRecord, index, sourceWidget) {                        
                            dropRecords[0].NFS_NIVEL = index;
                            nivelEAPFisicaDS.updateData(dropRecords[0]);
                            nivelEAPFisicaList.fetchData();
                        },
    Code:
    recordDrop: function (dropRecords, targetRecord, index, sourceWidget) {                        
                            dropRecords[0].NFS_NIVEL = index;
                            nivelEAPFisicaDS.updateData(dropRecords[0]);
                            this.fetchData();
                        },
    But the command ListGrid.FetchData () is not executed.

    If I use DataSource.FetchData () works! Why ListGrid.FetchData () does not work in this code?

    Thanks for your attention

    Comment


      #3
      Read the docs for fetchData() - it will not always cause a fetch.

      Comment


        #4
        Ok, but you can help me with some idea about the OP?

        Thanks for your attention.

        Comment


          #5
          I got run the fetch by calling the invalidateCache();

          "Resolved" my problem, but not the best way. For there would need to demonstrate the message "loading" to the user.

          There is another way to keep the correct order of records in the grid without calling the fetch again?

          Thanks

          Comment


            #6
            Someone help me?

            I need the same functionality on another interface. But I can not use the invalidateCache() because I can not reload the grid.

            I just need to drop the work after I called the UpdateData() from within the event recordDrop().


            Thanks all

            Comment


              #7
              anybody???

              Comment


                #8
                I tried this:

                Code:
                recordDrop: function (dropRecords, targetRecord, index, sourceWidget) {
                    dropRecords[0].NFS_NIVEL = index;
                    this.updateData(dropRecords[0], this.Super("recordDrop", arguments));
                }
                Calling this.Super in UpdateData callBack theoretically supposed to work. But it did not work.

                Anybody help me?!

                Comment


                  #9
                  Code:
                  this.updateData(dropRecords[0], this.Super("recordDrop", arguments));
                  this isn't going to call 'Super' in the callback, you have to use a string method or wrap it in a function

                  Comment


                    #10
                    Hi claudiobosticco

                    The 'Super' is executed instead.

                    I see the command being executed because the item appears in ListGrid being 'dropped'. If I remove this command from the callback, the item does not appear to be 'dropped' - it is static.

                    The problem is that the item is 'dropped' and 'UNdropped' shortly thereafter automatically. I do not know why this happens and I need help to solve this.

                    Thanks for your attention.

                    Comment


                      #11
                      How can I get some help?

                      Comment


                        #12
                        I don't know if it's the problem, but the call:
                        Code:
                        this.updateData(dropRecords[0], this.Super("recordDrop", arguments));
                        will not call Super in the callback, instead will call it immediately.

                        you have to write something like:

                        Code:
                        this.updateData(
                            dropRecords[0], 
                            function(dsResponse, data, dsRequest) {
                                dsRequest.that.Super("recordDrop", dsRequest.args);
                            },
                            {that: this, args:arguments}
                        );

                        Comment


                          #13
                          Thanks for your attention claudio!

                          You're right! Thus now the 'Super' was called only after running the UpdateData ();

                          But did not solve my problem, because the recordDrop () is doubling the record rather than drop it.

                          In any event, could solve otherwise. I created a datasource just like the one used in ListGrid to be called only for this Update.

                          Code:
                          recordDrop: function (dropRecords, targetRecord, index, sourceWidget) {
                              dropRecords[0].NFS_NIVEL = index;
                              nivelEAPFisicaAuxDS.updateData(dropRecords[0]); //a copy of the main datasource
                              this.Super("recordDrop", arguments);
                          }
                          Now its work!
                          Thank you very much for your attention!!

                          Comment

                          Working...
                          X