Loading ...
Sorry, an error occurred while loading the content.
 

Editable datatable..

Expand Messages
  • Nagasamudram, Prasanna Kumar
    Hi I have seen the sample that displays a text box when a particular cell in a data table is clicked. When the uses modifies the text and presses the ENTER key
    Message 1 of 21 , Aug 17, 2007

      Hi

       

       

      I have seen the sample that displays a text box when a particular cell in a data table is clicked.

       

      When the uses modifies the text and presses the ENTER key the data is saved and is reflected on the fly.

       

      I want to catch this ENTER key and display a confirmation dialog box , if the user presses OK then I need to call a function before saving the data.

       

      Can you please let me know how to catch this ENTER key.

       

       

       

      Thanks

      Prasanna

    • Satyam
      A good place to do this would be to assign a validator function to the columns you will edit such that if the user confirms, you return the received value
      Message 2 of 21 , Aug 17, 2007
        A good place to do this would be to assign a validator function to the columns you will edit such that if the user confirms, you return the received value (first argument, newData) indicating it validated Ok, otherwise, you return null and the validation will fail. 
         
        See the method:
         
        YAHOO.widget.DataTable.prototype.saveCellEditor 
         
        in datatable-beta.js and you will see how it would work. I think it is the least intrusive way to do what you are asking for.  This method is called to save the data for any cell editor, whichever way the user ends the inline editing and the call to:
         
        this._oCellEditor.validator.call(this, newData, oldData);
         
        is a good place to catch the right moment.
         
        Satyam
         
         
         
        ----- Original Message -----
        Sent: Friday, August 17, 2007 10:25 AM
        Subject: [ydn-javascript] Editable datatable..

        Hi

         

         

        I have seen the sample that displays a text box when a particular cell in a data table is clicked.

         

        When the uses modifies the text and presses the ENTER key the data is saved and is reflected on the fly.

         

        I want to catch this ENTER key and display a confirmation dialog box , if the user presses OK then I need to call a function before saving the data.

         

        Can you please let me know how to catch this ENTER key.

         

         

         

        Thanks

        Prasanna


        No virus found in this incoming message.
        Checked by AVG Free Edition.
        Version: 7.5.484 / Virus Database: 269.12.0/957 - Release Date: 16/08/2007 13:46
      • Nagasamudram, Prasanna Kumar
        Hi Satyam I was able to catch the moment when the editor is about to save the data, where I will display a dialog box, which says do you want to really
        Message 3 of 21 , Aug 28, 2007

          Hi Satyam

           

          I was able to catch the moment when the editor is about to save the data, where I will display a dialog box, which says “do you want to really commit?”, clicking on yes I can call the savecellEditor.

           

          But my problem is say we have the following

           

           

          Formatter

          {

                      callDialog()

                      return something based on the dialog or the flag

          }

           

           

          callDialog()

          {

           

                      handleOK {   saveCellEditor() or may be set a flag}

                      handleCANCEL { do Nothing}

           

          }

           

           

          By the time I click on the OK button of the dialog box, Formatter should have done its job of displaying the dialog box, but has nothing to return.

           

           

          Thanks

          Prasanna

           


          From: ydn-javascript@yahoogroups.com [mailto: ydn-javascript@yahoogroups.com ] On Behalf Of Satyam
          Sent: Friday, August 17, 2007 2:21 PM
          To: ydn-javascript@yahoogroups.com
          Subject: Re: [ydn-javascript] Editable datatable..

           

          A good place to do this would be to assign a validator function to the columns you will edit such that if the user confirms, you return the received value (first argument, newData) indicating it validated Ok, otherwise, you return null and the validation will fail. 

           

          See the method:

           

          YAHOO.widget. DataTable. prototype. saveCellEditor 

           

          in datatable-beta. js and you will see how it would work. I think it is the least intrusive way to do what you are asking for.  This method is called to save the data for any cell editor, whichever way the user ends the inline editing and the call to:

           

          this._oCellEditor. validator. call(this, newData, oldData);

           

          is a good place to catch the right moment.

           

          Satyam

           

           

           

          ----- Original Message -----

          Sent: Friday, August 17, 2007 10:25 AM

          Subject: [ydn-javascript] Editable datatable..

           

          Hi

           

           

          I have seen the sample that displays a text box when a particular cell in a data table is clicked.

           

          When the uses modifies the text and presses the ENTER key the data is saved and is reflected on the fly.

           

          I want to catch this ENTER key and display a confirmation dialog box , if the user presses OK then I need to call a function before saving the data.

           

          Can you please let me know how to catch this ENTER key.

           

           

           

          Thanks

          Prasanna

          size=2 width="100%" align=center>

          No virus found in this incoming message.
          Checked by AVG Free Edition.
          Version: 7.5.484 / Virus Database: 269.12.0/957 - Release Date: 16/08/2007 13:46

        • Satyam
          I m a little confused, Formatter? that s used for displaying, I was talking about the validator.. Anyway, here is a little sample code that works and I hope
          Message 4 of 21 , Aug 28, 2007
            I'm a little confused, Formatter?  that's used for displaying, I was talking about the validator.. 
             
            Anyway, here is a little sample code that works and I hope will explain itself, just add the following to the column definition of any column you want to have further confirmation before saving:
             
            editor:"textbox",editorOptions:{validator:function(oData){
                 if (confirm('do you want to save?')) return oData;
                 return null;
                }}
             
            Satyam
             
            ----- Original Message -----
            Sent: Tuesday, August 28, 2007 1:22 PM
            Subject: RE: [ydn-javascript] Editable datatable..

            Hi Satyam

             

            I was able to catch the moment when the editor is about to save the data, where I will display a dialog box, which says “do you want to really commit?”, clicking on yes I can call the savecellEditor.

             

            But my problem is say we have the following

             

             

            Formatter

            {

                        callDialog()

                        return something based on the dialog or the flag

            }

             

             

            callDialog()

            {

             

                        handleOK {   saveCellEditor() or may be set a flag}

                        handleCANCEL { do Nothing}

             

            }

             

             

            By the time I click on the OK button of the dialog box, Formatter should have done its job of displaying the dialog box, but has nothing to return.

             

             

            Thanks

            Prasanna

             


            From: ydn-javascript@yahoogroups.com [mailto: ydn-javascript@yahoogroups.com ] On Behalf Of Satyam
            Sent: Friday, August 17, 2007 2:21 PM
            To: ydn-javascript@yahoogroups.com
            Subject: Re: [ydn-javascript] Editable datatable..

             

            A good place to do this would be to assign a validator function to the columns you will edit such that if the user confirms, you return the received value (first argument, newData) indicating it validated Ok, otherwise, you return null and the validation will fail. 

             

            See the method:

             

            YAHOO.widget. DataTable. prototype. saveCellEditor 

             

            in datatable-beta. js and you will see how it would work. I think it is the least intrusive way to do what you are asking for.  This method is called to save the data for any cell editor, whichever way the user ends the inline editing and the call to:

             

            this._oCellEditor. validator. call(this, newData, oldData);

             

            is a good place to catch the right moment.

             

            Satyam

             

             

             

            ----- Original Message -----

            Sent: Friday, August 17, 2007 10:25 AM

            Subject: [ydn-javascript] Editable datatable..

             

            Hi

             

             

            I have seen the sample that displays a text box when a particular cell in a data table is clicked.

             

            When the uses modifies the text and presses the ENTER key the data is saved and is reflected on the fly.

             

            I want to catch this ENTER key and display a confirmation dialog box , if the user presses OK then I need to call a function before saving the data.

             

            Can you please let me know how to catch this ENTER key.

             

             

             

            Thanks

            Prasanna

            size=2 width="100%" align=center>

            No virus found in this incoming message.
            Checked by AVG Free Edition.
            Version: 7.5.484 / Virus Database: 269.12.0/957 - Release Date: 16/08/2007 13:46


            No virus found in this incoming message.
            Checked by AVG Free Edition.
            Version: 7.5.484 / Virus Database: 269.12.10/976 - Release Date: 27/08/2007 18:20
          • Nagasamudram, Prasanna Kumar
            I meant validator and not Formatter. ________________________________ From: Nagasamudram, Prasanna Kumar Sent: Tuesday, August 28, 2007 4:53 PM To:
            Message 5 of 21 , Aug 28, 2007

              I meant validator and not Formatter.

               

               


              From: Nagasamudram, Prasanna Kumar
              Sent: Tuesday, August 28, 2007 4:53 PM
              To: ' ydn-javascript@yahoogroups.com '
              Subject: RE: [ydn-javascript] Editable datatable..

               

              Hi Satyam

               

              I was able to catch the moment when the editor is about to save the data, where I will display a dialog box, which says “do you want to really commit?”, clicking on yes I can call the savecellEditor.

               

              But my problem is say we have the following

               

               

              Formatter

              {

                          callDialog()

                          return something based on the dialog or the flag

              }

               

               

              callDialog()

              {

               

                          handleOK {   saveCellEditor() or may be set a flag}

                          handleCANCEL { do Nothing}

               

              }

               

               

              By the time I click on the OK button of the dialog box, Formatter should have done its job of displaying the dialog box, but has nothing to return.

               

               

              Thanks

              Prasanna

               


              From: ydn-javascript@yahoogroups.com [mailto: ydn-javascript@yahoogroups.com ] On Behalf Of Satyam
              Sent: Friday, August 17, 2007 2:21 PM
              To: ydn-javascript@yahoogroups.com
              Subject: Re: [ydn-javascript] Editable datatable..

               

              A good place to do this would be to assign a validator function to the columns you will edit such that if the user confirms, you return the received value (first argument, newData) indicating it validated Ok, otherwise, you return null and the validation will fail. 

               

              See the method:

               

              YAHOO.widget. DataTable. prototype. saveCellEditor 

               

              in datatable-beta. js and you will see how it would work. I think it is the least intrusive way to do what you are asking for.  This method is called to save the data for any cell editor, whichever way the user ends the inline editing and the call to:

               

              this._oCellEditor. validator. call(this, newData, oldData);

               

              is a good place to catch the right moment.

               

              Satyam

               

               

               

              ----- Original Message -----

              Sent: Friday, August 17, 2007 10:25 AM

              Subject: [ydn-javascript] Editable datatable..

               

              Hi

               

               

              I have seen the sample that displays a text box when a particular cell in a data table is clicked.

               

              When the uses modifies the text and presses the ENTER key the data is saved and is reflected on the fly.

               

              I want to catch this ENTER key and display a confirmation dialog box , if the user presses OK then I need to call a function before saving the data.

               

              Can you please let me know how to catch this ENTER key.

               

               

               

              Thanks

              Prasanna

              <hr size=2 width="100%" align=center>

              No virus found in this incoming message.
              Checked by AVG Free Edition.
              Version: 7.5.484 / Virus Database: 269.12.0/957 - Release Date: 16/08/2007 13:46

            • Nagasamudram, Prasanna Kumar
              Im sorry , I meant validator and not formatter. Also, I was trying to use YAHOO.widget.Dialog instead of using the javascript confirm . That solves my
              Message 6 of 21 , Aug 28, 2007

                Im sorry , I meant validator and not formatter.

                 

                Also, I was trying to use YAHOO.widget.Dialog instead of using the javascript “confirm”.

                 

                That solves my problem…

                 

                Thanks a lot

                 

                Prasanna

                 

                 

                 


                From: ydn-javascript@yahoogroups.com [mailto: ydn-javascript@yahoogroups.com ] On Behalf Of Satyam
                Sent: Tuesday, August 28, 2007 5:44 PM
                To: ydn-javascript@yahoogroups.com
                Subject: Re: [ydn-javascript] Editable datatable..

                 

                I'm a little confused, Formatter?  that's used for displaying, I was talking about the validator.. 

                 

                Anyway, here is a little sample code that works and I hope will explain itself, just add the following to the column definition of any column you want to have further confirmation before saving:

                 

                editor:"textbox",editorOptions: {validator: function( oData){
                     if (confirm('do you want to save?')) return oData;
                     return null;
                    }}

                 

                Satyam

                 

                ----- Original Message -----

                Sent: Tuesday, August 28, 2007 1:22 PM

                Subject: RE: [ydn-javascript] Editable datatable..

                 

                Hi Satyam

                 

                I was able to catch the moment when the editor is about to save the data, where I will display a dialog box, which says “do you want to really commit?”, clicking on yes I can call the savecellEditor.

                 

                But my problem is say we have the following

                 

                 

                Formatter

                {

                            callDialog()

                            return something based on the dialog or the flag

                }

                 

                 

                callDialog()

                {

                 

                            handleOK {   saveCellEditor( ) or may be set a flag}

                            handleCANCEL { do Nothing}

                 

                }

                 

                 

                By the time I click on the OK button of the dialog box, Formatter should have done its job of displaying the dialog box, but has nothing to return.

                 

                 

                Thanks

                Prasanna

                 


                From: ydn-javascript@ yahoogroups. com [mailto: ydn-javascript@ yahoogroups. com ] On Behalf Of Satyam
                Sent: Friday, August 17, 2007 2:21 PM
                To: ydn-javascript@ yahoogroups. com
                Subject: Re: [ydn-javascript] Editable datatable..

                 

                A good place to do this would be to assign a validator function to the columns you will edit such that if the user confirms, you return the received value (first argument, newData) indicating it validated Ok, otherwise, you return null and the validation will fail. 

                 

                See the method:

                 

                YAHOO.widget. DataTable. prototype. saveCellEditor 

                 

                in datatable-beta. js and you will see how it would work. I think it is the least intrusive way to do what you are asking for.  This method is called to save the data for any cell editor, whichever way the user ends the inline editing and the call to:

                 

                this._oCellEditor. validator. call(this, newData, oldData);

                 

                is a good place to catch the right moment.

                 

                Satyam

                 

                 

                 

                ----- Original Message -----

                Sent: Friday, August 17, 2007 10:25 AM

                Subject: [ydn-javascript] Editable datatable..

                 

                Hi

                 

                 

                I have seen the sample that displays a text box when a particular cell in a data table is clicked.

                 

                When the uses modifies the text and presses the ENTER key the data is saved and is reflected on the fly.

                 

                I want to catch this ENTER key and display a confirmation dialog box , if the user presses OK then I need to call a function before saving the data.

                 

                Can you please let me know how to catch this ENTER key.

                 

                 

                 

                Thanks

                Prasanna


                size=2 width="100%" align=center>

                No virus found in this incoming message.
                Checked by AVG Free Edition.
                Version: 7.5.484 / Virus Database: 269.12.0/957 - Release Date: 16/08/2007 13:46

              • Nagasamudram, Prasanna Kumar
                Hi Satyam Previous requirement was a confirmation before saving the data. Tha following solves the problem as you mentioned.
                Message 7 of 21 , Aug 31, 2007

                  Hi Satyam

                   

                   

                  Previous requirement was a confirmation before saving the data.

                  Tha following solves the problem as you mentioned.

                  editor:"textbox",editorOptions: {validator: function( oData){
                       if (confirm('do you want to save?')) return oData;
                       return null;
                      }}

                   

                  But now instead of a confirmation, I need to send and AJAX request.

                  One I get the AJAX response I should save the data.

                   

                  But since AJAX is asynchronous and the handler is a different function, can I make the validator wait for the AJAX response?

                  So that it can reurn oData or null appropriately …….

                   

                  Thanks

                  Prasanna

                   


                  From: ydn-javascript@yahoogroups.com [mailto: ydn-javascript@yahoogroups.com ] On Behalf Of Nagasamudram, Prasanna Kumar
                  Sent: Tuesday, August 28, 2007 6:36 PM
                  To: ydn-javascript@yahoogroups.com
                  Subject: RE: [ydn-javascript] Editable datatable..

                   

                  Im sorry , I meant validator and not formatter.

                   

                  Also, I was trying to use YAHOO.widget. Dialog instead of using the javascript “confirm”.

                   

                  That solves my problem…

                   

                  Thanks a lot

                   

                  Prasanna

                   

                   

                   


                  From: ydn-javascript@ yahoogroups. com [mailto: ydn-javascript@ yahoogroups. com ] On Behalf Of Satyam
                  Sent: Tuesday, August 28, 2007 5:44 PM
                  To: ydn-javascript@ yahoogroups. com
                  Subject: Re: [ydn-javascript] Editable datatable..

                   

                  I'm a little confused, Formatter?  that's used for displaying, I was talking about the validator.. 

                   

                  Anyway, here is a little sample code that works and I hope will explain itself, just add the following to the column definition of any column you want to have further confirmation before saving:

                   

                  editor:"textbox",editorOptions: {validator: function( oData){
                       if (confirm('do you want to save?')) return oData;
                       return null;
                      }}

                   

                  Satyam

                   

                  ----- Original Message -----

                  Sent: Tuesday, August 28, 2007 1:22 PM

                  Subject: RE: [ydn-javascript] Editable datatable..

                   

                  Hi Satyam

                   

                  I was able to catch the moment when the editor is about to save the data, where I will display a dialog box, which says “do you want to really commit?”, clicking on yes I can call the savecellEditor.

                   

                  But my problem is say we have the following

                   

                   

                  Formatter

                  {

                              callDialog()

                              return something based on the dialog or the flag

                  }

                   

                   

                  callDialog()

                  {

                   

                              handleOK {   saveCellEditor( ) or may be set a flag}

                              handleCANCEL { do Nothing}

                   

                  }

                   

                   

                  By the time I click on the OK button of the dialog box, Formatter should have done its job of displaying the dialog box, but has nothing to return.

                   

                   

                  Thanks

                  Prasanna

                   


                  From: ydn-javascript@ yahoogroups. com [mailto: ydn-javascript@ yahoogroups. com ] On Behalf Of Satyam
                  Sent: Friday, August 17, 2007 2:21 PM
                  To: ydn-javascript@ yahoogroups. com
                  Subject: Re: [ydn-javascript] Editable datatable..

                   

                  A good place to do this would be to assign a validator function to the columns you will edit such that if the user confirms, you return the received value (first argument, newData) indicating it validated Ok, otherwise, you return null and the validation will fail. 

                   

                  See the method:

                   

                  YAHOO.widget. DataTable. prototype. saveCellEditor 

                   

                  in datatable-beta. js and you will see how it would work. I think it is the least intrusive way to do what you are asking for.  This method is called to save the data for any cell editor, whichever way the user ends the inline editing and the call to:

                   

                  this._oCellEditor. validator. call(this, newData, oldData);

                   

                  is a good place to catch the right moment.

                • Satyam
                  That is, indeed, a problem. The best alternative I found is to redefine the saveCellEditor method. This is how the original looks like, with the original
                  Message 8 of 21 , Aug 31, 2007
                    That is, indeed, a problem.  The best alternative I found is to redefine the saveCellEditor method. 
                     
                    This is how the original looks like, with the original comments stripped and my own added:
                     
                    YAHOO.widget.DataTable.prototype.saveCellEditor = function() {
                        if(this._oCellEditor.isActive) {
                            var newData = this._oCellEditor.value;
                            var oldData = this._oCellEditor.record.getData(this._oCellEditor.column.key);
                     
                            if(this._oCellEditor.validator) {
                                this._oCellEditor.value = this._oCellEditor.validator.call(this, newData, oldData);
                                if(this._oCellEditor.value === null ) {
                            //  -----  This is what you do on error
                                    this.resetCellEditor();
                                    this.fireEvent("editorRevertEvent",
                                            {editor:this._oCellEditor, oldData:oldData, newData:newData});
                            // ----- up to here
                                    return;
                                }
                            }
                    // ----- This is what you do on success
                            this._oRecordSet.updateKey(this._oCellEditor.record, this._oCellEditor.column.key, this._oCellEditor.value);
                            this.formatCell(this._oCellEditor.cell);
                            this.resetCellEditor();
                            this.fireEvent("editorSaveEvent",
                                    {editor:this._oCellEditor, oldData:oldData, newData:newData});
                    // ---- up to here.
                     

                        }
                        else {
                        }
                    };
                     
                    So, what I did is to have the part that handles a failed validation made into an inner function, since it will be called in several places.  Where the failure secion is I put a call to this inner function.
                     
                    I cut the 'success' part and save it elsewhere since we are going to use id.  In its place, I put the call to asyncRequest and end the function.  In the success callback to asyncRequest I put the success section I saved. 
                     
                    On the 'failure' callback to asyncRequest I call the failure function, that's why I put it in an inner function.  Actually, even on a sucess return from the server, you have to check if there was any error from the database since the failure callback only handles communication errors, if there are any logic errors, you have to handle those.  In case of error, I call the failure function.  My own is somewhat different, bits and pieces that I added or deleted from the original so I am making this one right here on the message, cutting and pasting and writing here.  It probably doesn't work as is, but I hope it will give you the general idea.  I tried to preserve as much of the original function as possible, even the comments I put in the one above.
                     
                    YAHOO.widget.DataTable.prototype.saveCellEditor = function() {
                       // ++++ this is the inner function to handle the several possible failure conditions
                        var onFailure = function (msg) {
                            alert(msg);
                            //  -----  This is what you do on error
                               this.resetCellEditor();
                               this.fireEvent("editorRevertEvent",
                                            {editor:this._oCellEditor, oldData:oldData, newData:newData});
                            // ----- up to here
                      };
                    // +++ this comes from the original exdcept for the part I cut to place in the function above.
                        if(this._oCellEditor.isActive) {
                            var newData = this._oCellEditor.value;
                            var oldData = this._oCellEditor.record.getData(this._oCellEditor.column.key);
                     
                            if(this._oCellEditor.validator) {
                                this._oCellEditor.value = this._oCellEditor.validator.call(this, newData, oldData);
                                if(this._oCellEditor.value === null ) {
                                    onFailure('validation');
                                    return;
                                }
                            }
                     
                    // ++++++ from here on I added new, except for the 'success' case pasted in.
                        YAHOO.util.Connection.asyncRequest('GET','yourURL with newData,fieldname and primary as arguments ',
                            {
                                success: function (o) {
                                    if (no error on reply from server) {
                                    // ----- This is what you do on success
                                        this._oRecordSet.updateKey(this._oCellEditor.record, this._oCellEditor.column.key, this._oCellEditor.value);
                                        this.formatCell(this._oCellEditor.cell);
                                        this.resetCellEditor();
                                        this.fireEvent("editorSaveEvent",
                                                {editor:this._oCellEditor, oldData:oldData, newData:newData});
                                    // ---- up to here.
                                } else {
                                    onFailure(o.responseText);
                            },
                            failure: function(o) {
                                onFailure(o.statusText);
                            },
                            scope: this
                        );
                     

                        }
                        else {
                        }
                    };

                    In my version I don't close the inline editor on error.  The user has either to fix the error (if it is a validation error, client or server side, he can probably fix it) or cancel out of it. 
                     
                    I don't fire the editorRevertEvent and editorSaveEvent since I don't listen to them.  I particularly feel the editorSaveEvent fires too late. That is where you would normally hook for the AJAX call to the server, but the DataTable is already changed and the editor closed as if everything was ok and if there is an error, the user might have already navigated away from the page trusting everything was Ok.  Anyhow, moving that event up doesn't help much since, due to the A in AJAX, you cannot wait in the event for an answer, so the whole thing doesn't quite work. 
                     
                    I also have a Dialog which I use instead of both alert() and confirm(), just for the look and feel. 
                     
                    I also use a POST request instead of GET to allow for large field contents.
                     
                     
                    Finally, if you are using JSON, I found that using an 'envelope' in the reply makes things more flexible.  My 'envelope' looks like this:
                     
                    {
                        replyCode:200, replyText:"Ok",
                        data:[{ ... } , ... ]
                    }
                     
                    You could do more or less the same thing with XML.  Whichever the message format, make sure to the reply codes are easy to reach.
                     
                    The data element is optional and may contain whatever was requested, but sometimes you just want to know whether it succeeded or not. I use that envelope on all AJAX replies, even those from DataSource to fill the DataTable.   Enclosing the reply in the envelope with the reply code and text is quite handy.  Thus, in the 'success' callback, by simply eval(uating) o.responseText you can easily pick any error messages from the server:
                     
                                success: function (o) {
                                    var reply = eval('(' + o.responseText + ')');  // better enclose this in a try-catch to handle possible errors
                                    if (r.replyCode == 200 ) {
                     
                                    } else {
                                        onFailure(r.replyText);
                                    }
                     
                    Just like in HTTP I use 200 to indicate Ok, 2xx for mostly ok, 5xx for errors.
                     
                    Are you using PHP on the server side?  Then check:  http://www.satyam.com.ar/int/PhpJson.htm
                     
                     
                    Wish you luck!
                     
                    Satyam
                    ----- Original Message -----
                    Sent: Friday, August 31, 2007 2:55 PM
                    Subject: RE: [ydn-javascript] Editable datatable..

                    Hi Satyam

                     

                     

                    Previous requirement was a confirmation before saving the data.

                    Tha following solves the problem as you mentioned.

                    editor:"textbox",editorOptions: {validator: function( oData){
                         if (confirm('do you want to save?')) return oData;
                         return null;
                        }}

                     

                    But now instead of a confirmation, I need to send and AJAX request.

                    One I get the AJAX response I should save the data.

                     

                    But since AJAX is asynchronous and the handler is a different function, can I make the validator wait for the AJAX response?

                    So that it can reurn oData or null appropriately …….

                     

                    Thanks

                    Prasanna

                     


                    From: ydn-javascript@yahoogroups.com [mailto: ydn-javascript@yahoogroups.com ] On Behalf Of Nagasamudram, Prasanna Kumar
                    Sent: Tuesday, August 28, 2007 6:36 PM
                    To: ydn-javascript@yahoogroups.com
                    Subject: RE: [ydn-javascript] Editable datatable..

                     

                    Im sorry , I meant validator and not formatter.

                     

                    Also, I was trying to use YAHOO.widget. Dialog instead of using the javascript “confirm”.

                     

                    That solves my problem…

                     

                    Thanks a lot

                     

                    Prasanna

                     

                     

                     


                    From:ydn-javascript@ yahoogroups. com [mailto: ydn-javascript@ yahoogroups. com ] On Behalf Of Satyam
                    Sent: Tuesday, August 28, 2007 5:44 PM
                    To: ydn-javascript@ yahoogroups. com
                    Subject: Re: [ydn-javascript] Editable datatable..

                     

                    I'm a little confused, Formatter?  that's used for displaying, I was talking about the validator.. 

                     

                    Anyway, here is a little sample code that works and I hope will explain itself, just add the following to the column definition of any column you want to have further confirmation before saving:

                     

                    editor:"textbox",editorOptions: {validator: function( oData){
                         if (confirm('do you want to save?')) return oData;
                         return null;
                        }}

                     

                    Satyam

                     

                    (Message over 64 KB, truncated)

                  • Nagasamudram, Prasanna Kumar
                    Thanks a lot Satyam.... I have a very basic question here.... This solution involves changing the yui code. Is this allowed, I mean are we supposed to give
                    Message 9 of 21 , Sep 3, 2007

                      Thanks a lot Satyam….

                       

                      I have a very basic question here….

                      This solution involves changing the yui code.

                       

                      Is this allowed, I mean are we supposed to give this as a patch and then make use of the new release?

                       

                      Thanks

                      Prasanna

                       

                       

                       


                      From: ydn-javascript@yahoogroups.com [mailto:ydn-javascript@yahoogroups.com] On Behalf Of Satyam
                      Sent: Friday, August 31, 2007 10:38 PM
                      To: ydn-javascript@yahoogroups.com
                      Subject: Re: [ydn-javascript] Editable datatable..

                       

                      That is, indeed, a problem.  The best alternative I found is to redefine the saveCellEditor method. 

                       

                      This is how the original looks like, with the original comments stripped and my own added:

                       

                      YAHOO.widget. DataTable. prototype. saveCellEditor = function() {

                          if(this._oCellEdito r.isActive) {
                              var newData = this._oCellEditor. value;
                              var oldData = this._oCellEditor. record.getData( this._oCellEdito r.column. key);

                       

                              if(this._oCellEdito r.validator) {
                                  this._oCellEditor. value = this._oCellEditor. validator. call(this, newData, oldData);
                                  if(this._oCellEdito r.value === null ) {

                              //  -----  This is what you do on error
                                      this.resetCellEdito r();
                                      this.fireEvent( "editorRevertEve nt",
                                              {editor:this. _oCellEditor, oldData:oldData, newData:newData} );
                              // ----- up to here
                                      return;

                                  }
                              }

                      // ----- This is what you do on success

                              this._oRecordSet. updateKey( this._oCellEdito r.record, this._oCellEditor. column.key, this._oCellEditor. value);

                              this.formatCell( this._oCellEdito r.cell);

                              this.resetCellEdito r();

                              this.fireEvent( "editorSaveEvent ",
                                      {editor:this. _oCellEditor, oldData:oldData, newData:newData} );

                      // ---- up to here.

                       


                          }
                          else {
                          }
                      };

                       

                      So, what I did is to have the part that handles a failed validation made into an inner function, since it will be called in several places.  Where the failure secion is I put a call to this inner function.

                       

                      I cut the 'success' part and save it elsewhere since we are going to use id.  In its place, I put the call to asyncRequest and end the function.  In the success callback to asyncRequest I put the success section I saved. 

                       

                      On the 'failure' callback to asyncRequest I call the failure function, that's why I put it in an inner function.  Actually, even on a sucess return from the server, you have to check if there was any error from the database since the failure callback only handles communication errors, if there are any logic errors, you have to handle those.  In case of error, I call the failure function.  My own is somewhat different, bits and pieces that I added or deleted from the original so I am making this one right here on the message, cutting and pasting and writing here.  It probably doesn't work as is, but I hope it will give you the general idea.  I tried to preserve as much of the original function as possible, even the comments I put in the one above.

                       

                      YAHOO.widget. DataTable. prototype. saveCellEditor = function() {

                         // ++++ this is the inner function to handle the several possible failure conditions

                          var onFailure = function (msg) {

                              alert(msg);
                              //  -----  This is what you do on error
                                 this.resetCellEdito r();
                                 this.fireEvent( "editorRevertEve nt",
                                              {editor:this. _oCellEditor, oldData:oldData, newData:newData} );

                              // ----- up to here
                        };

                      // +++ this comes from the original exdcept for the part I cut to place in the function above.

                          if(this._oCellEdito r.isActive) {
                              var newData = this._oCellEditor. value;
                              var oldData = this._oCellEditor. record.getData( this._oCellEdito r.column. key);

                       

                              if(this._oCellEdito r.validator) {
                                  this._oCellEditor. value = this._oCellEditor. validator. call(this, newData, oldData);
                                  if(this._oCellEdito r.value === null ) {

                                      onFailure('validati on');

                                      return;

                                  }
                              }

                       

                      // ++++++ from here on I added new, except for the 'success' case pasted in.

                          YAHOO.util.Connecti on.asyncRequest( 'GET','yourURL with newData,fieldname and primary as arguments ',

                              {

                                  success: function (o) {

                                      if (no error on reply from server) {

                                      // ----- This is what you do on success

                                          this._oRecordSet. updateKey( this._oCellEdito r.record, this._oCellEditor. column.key, this._oCellEditor. value);

                                          this.formatCell( this._oCellEdito r.cell);

                                          this.resetCellEdito r();

                                          this.fireEvent( "editorSaveEvent ",
                                                  {editor:this. _oCellEditor, oldData:oldData, newData:newData} );

                                      // ---- up to here.

                                  } else {

                                      onFailure(o. responseText) ;

                              },

                              failure: function(o) {

                                  onFailure(o. statusText) ;

                              },

                              scope: this

                          );

                       


                          }
                          else {
                          }
                      };


                      In my version I don't close the inline editor on error.  The user has either to fix the error (if it is a validation error, client or server side, he can probably fix it) or cancel out of it. 

                       

                      I don't fire the editorRevertEvent and editorSaveEvent since I don't listen to them.  I particularly feel the editorSaveEvent fires too late. That is where you would normally hook for the AJAX call to the server, but the DataTable is already changed and the editor closed as if everything was ok and if there is an error, the user might have already navigated away from the page trusting everything was Ok.  Anyhow, moving that event up doesn't help much since, due to the A in AJAX , you cannot wait in the event for an answer, so the whole thing doesn't quite work. 

                       

                      I also have a Dialog which I use instead of both alert() and confirm(), just for the look and feel. 

                       

                      I also use a POST request instead of GET to allow for large field contents.

                       

                       

                      Finally, if you are using JSON, I found that using an 'envelope' in the reply makes things more flexible.  My 'envelope' looks like this:

                       

                      {
                          replyCode:200, replyText:"Ok" ,
                          data:[{ ... } , ... ]
                      }

                       

                      You could do more or less the same thing with XML.  Whichever the message format, make sure to the reply codes are easy to reach.

                       

                      The data element is optional and may contain whatever was requested, but sometimes you just want to know whether it succeeded or not. I use that envelope on all AJAX replies, even those from DataSource to fill the DataTable.   Enclosing the reply in the envelope with the reply code and text is quite handy.  Thus, in the 'success' callback, by simply eval(uating) o.responseText you can easily pick any error messages from the server:

                       

                                  success: function (o) {

                                      var reply = eval('(' + o.responseText + ')');  // better enclose this in a try-catch to handle possible errors

                                      if (r.replyCode == 200 ) {

                       

                                      } else {

                                          onFailure(r. replyText) ;

                                      }

                       

                      Just like in HTTP I use 200 to indicate Ok, 2xx for mostly ok, 5xx for errors.

                       

                      Are you using PHP on the server side?  Then check:  http://www.satyam. com.ar/int/ PhpJson.htm



                      (Message over 64 KB, truncated)
                    • Satyam
                      It is better that you don t change the original distribution files, I did that once and when the update came, it was tough to check the changes. What I now
                      Message 10 of 21 , Sep 3, 2007
                        It is better that you don't change the original distribution files, I did that once and when the update came, it was tough to check the changes. 
                         
                        What I now have is a separate file with all my patches that I load after the file to be patched so that its definitions overwrite the original ones.  That makes it easy when a new version comes to pick the methods that were patched and check if they are still necesary.
                         
                        I actually have my own customized version of DataTable (using YAHOO.lang.extend) where I have several of the basic settings already taken care of and I can redefine the methods in that inherited DataTable.  If there were to be any licensing issues with modifying the original library, this would take care of them. 
                         
                        Anyway, redefining the original or your inherited version makes no difference when update time comes, you'll have to check those patches anyway, so it is good to have them all in one place. 
                         
                        Satyam
                         
                        ----- Original Message -----
                        Sent: Monday, September 03, 2007 10:05 AM
                        Subject: RE: [ydn-javascript] Editable datatable..

                        Thanks a lot Satyam….

                         

                        I have a very basic question here….

                        This solution involves changing the yui code.

                         

                        Is this allowed, I mean are we supposed to give this as a patch and then make use of the new release?

                         

                        Thanks

                        Prasanna

                         

                         

                         


                        From: ydn-javascript@yahoogroups.com [mailto:ydn-javascript@yahoogroups.com] On Behalf Of Satyam
                        Sent: Friday, August 31, 2007 10:38 PM
                        To: ydn-javascript@yahoogroups.com
                        Subject: Re: [ydn-javascript] Editable datatable..

                         

                        That is, indeed, a problem.  The best alternative I found is to redefine the saveCellEditor method. 

                         

                        This is how the original looks like, with the original comments stripped and my own added:

                         

                        YAHOO.widget. DataTable. prototype. saveCellEditor = function() {

                            if(this._oCellEdito r.isActive) {
                                var newData = this._oCellEditor. value;
                                var oldData = this._oCellEditor. record.getData( this._oCellEdito r.column. key);

                         

                                if(this._oCellEdito r.validator) {
                                    this._oCellEditor. value = this._oCellEditor. validator. call(this, newData, oldData);
                                    if(this._oCellEdito r.value === null ) {

                                //  -----  This is what you do on error
                                        this.resetCellEdito r();
                                        this.fireEvent( "editorRevertEve nt",
                                                {editor:this. _oCellEditor, oldData:oldData, newData:newData} );
                                // ----- up to here
                                        return;

                                    }
                                }

                        // ----- This is what you do on success

                                this._oRecordSet. updateKey( this._oCellEdito r.record, this._oCellEditor. column.key, this._oCellEditor. value);

                                this.formatCell( this._oCellEdito r.cell);

                                this.resetCellEdito r();

                                this.fireEvent( "editorSaveEvent ",
                                        {editor:this. _oCellEditor, oldData:oldData, newData:newData} );

                        // ---- up to here.

                         


                            }
                            else {
                            }
                        };

                         

                        So, what I did is to have the part that handles a failed validation made into an inner function, since it will be called in several places.  Where the failure secion is I put a call to this inner function.

                         

                        I cut the 'success' part and save it elsewhere since we are going to use id.  In its place, I put the call to asyncRequest and end the function.  In the success callback to asyncRequest I put the success section I saved. 

                         

                        On the 'failure' callback to asyncRequest I call the failure function, that's why I put it in an inner function.  Actually, even on a sucess return from the server, you have to check if there was any error from the database since the failure callback only handles communication errors, if there are any logic errors, you have to handle those.  In case of error, I call the failure function.  My own is somewhat different, bits and pieces that I added or deleted from the original so I am making this one right here on the message, cutting and pasting and writing here.  It probably doesn't work as is, but I hope it will give you the general idea.  I tried to preserve as much of the original function as possible, even the comments I put in the one above.

                         

                        YAHOO.widget. DataTable. prototype. saveCellEditor = function() {

                           // ++++ this is the inner function to handle the several possible failure conditions

                            var onFailure = function (msg) {

                                alert(msg);
                                //  -----  This is what you do on error
                                   this.resetCellEdito r();
                                   this.fireEvent( "editorRevertEve nt",
                                                {editor:this. _oCellEditor, oldData:oldData, newData:newData} );

                                // ----- up to here
                          };

                        // +++ this comes from the original exdcept for the part I cut to place in the function above.

                            if(this._oCellEdito r.isActive) {
                                var newData = this._oCellEditor. value;
                                var oldData = this._oCellEditor. record.getData( this._oCellEdito r.column. key);

                         

                                if(this._oCellEdito r.validator) {
                                    this._oCellEditor. value = this._oCellEditor. validator. call(this, newData, oldData);
                                    if(this._oCellEdito r.value === null ) {

                                        onFailure('validati on');

                                        return;

                                    }
                                }

                         

                        // ++++++ from here on I added new, except for the 'success' case pasted in.

                            YAHOO.util.Connecti on.asyncRequest( 'GET','yourURL with newData,fieldname and primary as arguments ',

                                {

                                    success: function (o) {

                                        if (no error on reply from server) {

                                        // ----- This is what you do on success

                                            this._oRecordSet. updateKey( this._oCellEdito r.record, this._oCellEditor. column.key, this._oCellEditor. value);

                                            this.formatCell( this._oCellEdito r.cell);

                                            this.resetCellEdito r();

                                            this.fireEvent( "editorSaveEvent ",
                                                    {editor:this. _oCellEditor, oldData:oldData, newData:newData} );

                                        // ---- up to here.

                                    } else {

                                        onFailure(o. responseText) ;

                                },

                                failure: function(o) {

                                    onFailure(o. statusText) ;

                                },

                                scope: this

                            );

                         


                            }
                            else {
                            }
                        };


                        In my version I don't close the inline editor on error.  The user has either to fix the error (if it is a validation error, client or server side, he can probably fix it) or cancel out of it. 

                         

                        I don't fire the editorRevertEvent and editorSaveEvent since I don't listen to them.  I particularly feel the editorSaveEvent fires too late. That is where you would normally hook for the AJAX call to the server, but the DataTable is already changed and the editor closed as if everything was ok and if there is an error, the user might have already navigated away from the page trusting everything was Ok.  Anyhow, moving that event up doesn't help much since, due to the A in AJAX , you cannot wait in the event for an answer, so the whole thing doesn't quite work. 

                         

                        I also have a Dialog which I use instead of both alert() and confirm(), just for the look and feel. 

                         

                        I also use a POST request instead of GET to allow for large field contents.

                         

                         

                        Finally, if you are using JSON, I found that using an 'envelope' in the reply makes things more flexible.  My 'envelope' looks like this:

                         

                        {
                            replyCode:200, replyText:"Ok" ,
                            data:[{ ... } , ... ]
                        }

                         

                        You could do more or less the same thing with XML.  Whichever the message format, make sure to the reply codes are easy to reach.

                         

                        The data element is optional and may contain whatever was requested, but sometimes you just want to know whether it succ

                        (Message over 64 KB, truncated)

                      • Nagasamudram, Prasanna Kumar
                        Hi Satyam editor: textbox ,editorOptions:{validator:function(oData){ if (confirm( do you want to save? )) return oData; return null; }} Here oData refers to
                        Message 11 of 21 , Sep 4, 2007

                          Hi Satyam

                           

                          editor:"textbox",editorOptions: {validator: function( oData){
                               if (confirm('do you want to save?')) return oData;
                               return null;
                              }}

                           

                           

                          Here oData refers to the actual data. (of that particular cell).

                           

                          Is there a way to get the record from this…

                           

                          I mean I would like to send an Ajax request using the other fields in the row.

                           

                          Is there something like

                           

                          record = getRecord(oData)

                           

                          and then use record.someotherfield etc…

                           

                           

                          Thanks

                          Prasanna

                           


                          From: ydn-javascript@yahoogroups.com [mailto: ydn-javascript@yahoogroups.com ] On Behalf Of Satyam
                          Sent: Tuesday, August 28, 2007 5:44 PM
                          To: ydn-javascript@yahoogroups.com
                          Subject: Re: [ydn-javascript] Editable datatable..

                           

                          I'm a little confused, Formatter?  that's used for displaying, I was talking about the validator.. 

                           

                          Anyway, here is a little sample code that works and I hope will explain itself, just add the following to the column definition of any column you want to have further confirmation before saving:

                           

                          editor:"textbox",editorOptions: {validator: function( oData){
                               if (confirm('do you want to save?')) return oData;
                               return null;
                              }}

                           

                          Satyam

                           

                          ----- Original Message -----

                          Sent: Tuesday, August 28, 2007 1:22 PM

                          Subject: RE: [ydn-javascript] Editable datatable..

                           

                          Hi Satyam

                           

                          I was able to catch the moment when the editor is about to save the data, where I will display a dialog box, which says “do you want to really commit?”, clicking on yes I can call the savecellEditor.

                           

                          But my problem is say we have the following

                           

                           

                          Formatter

                          {

                                      callDialog()

                                      return something based on the dialog or the flag

                          }

                           

                           

                          callDialog()

                          {

                           

                                      handleOK {   saveCellEditor( ) or may be set a flag}

                                      handleCANCEL { do Nothing}

                           

                          }

                           

                           

                          By the time I click on the OK button of the dialog box, Formatter should have done its job of displaying the dialog box, but has nothing to return.

                           

                           

                          Thanks

                          Prasanna

                           


                          From: ydn-javascript@ yahoogroups. com [mailto: ydn-javascript@ yahoogroups. com ] On Behalf Of Satyam
                          Sent: Friday, August 17, 2007 2:21 PM
                          To: ydn-javascript@ yahoogroups. com
                          Subject: Re: [ydn-javascript] Editable datatable..

                           

                          A good place to do this would be to assign a validator function to the columns you will edit such that if the user confirms, you return the received value (first argument, newData) indicating it validated Ok, otherwise, you return null and the validation will fail. 

                           

                          See the method:

                           

                          YAHOO.widget. DataTable. prototype. saveCellEditor 

                           

                          in datatable-beta. js and you will see how it would work. I think it is the least intrusive way to do what you are asking for.  This method is called to save the data for any cell editor, whichever way the user ends the inline editing and the call to:

                           

                          this._oCellEditor. validator. call(this, newData, oldData);

                           

                          is a good place to catch the right moment.

                           

                          Satyam

                           

                           

                           

                          ----- Original Message -----

                          Sent: Friday, August 17, 2007 10:25 AM

                          Subject: [ydn-javascript] Editable datatable..

                           

                          Hi

                           

                           

                          I have seen the sample that displays a text box when a particular cell in a data table is clicked.

                           

                          When the uses modifies the text and presses the ENTER key the data is saved and is reflected on the fly.

                           

                          I want to catch this ENTER key and display a confirmation dialog box , if the user presses OK then I need to call a function before saving the data.

                           


                          (Message over 64 KB, truncated)

                        • Satyam
                          Yes: MyDataTable.getCellEditor().record See: http://developer.yahoo.com/yui/docs/YAHOO.widget.DataTable.html#getCellEditor There is a lot of information in
                          Message 12 of 21 , Sep 4, 2007
                            Yes:
                             
                            MyDataTable.getCellEditor().record
                             
                            See:
                             
                             
                            There is a lot of information in that object.  There is only one cell editor active at a time and it contains all you could possibly care about a cell being edited.
                             
                            Satyam
                             
                            ----- Original Message -----
                            Sent: Tuesday, September 04, 2007 9:43 AM
                            Subject: RE: [ydn-javascript] Editable datatable..

                            Hi Satyam

                             

                            editor:"textbox",editorOptions: {validator: function( oData){
                                 if (confirm('do you want to save?')) return oData;
                                 return null;
                                }}

                             

                             

                            Here oData refers to the actual data. (of that particular cell).

                             

                            Is there a way to get the record from this…

                             

                            I mean I would like to send an Ajax request using the other fields in the row.

                             

                            Is there something like

                             

                            record = getRecord(oData)

                             

                            and then use record.someotherfield etc…

                             

                             

                            Thanks

                            Prasanna

                             


                            From: ydn-javascript@yahoogroups.com [mailto: ydn-javascript@yahoogroups.com ] On Behalf Of Satyam
                            Sent: Tuesday, August 28, 2007 5:44 PM
                            To: ydn-javascript@yahoogroups.com
                            Subject: Re: [ydn-javascript] Editable datatable..

                             

                            I'm a little confused, Formatter?  that's used for displaying, I was talking about the validator.. 

                             

                            Anyway, here is a little sample code that works and I hope will explain itself, just add the following to the column definition of any column you want to have further confirmation before saving:

                             

                            editor:"textbox",editorOptions: {validator: function( oData){
                                 if (confirm('do you want to save?')) return oData;
                                 return null;
                                }}

                             

                            Satyam

                             

                            ----- Original Message -----

                            Sent: Tuesday, August 28, 2007 1:22 PM

                            Subject: RE: [ydn-javascript] Editable datatable..

                             

                            Hi Satyam

                             

                            I was able to catch the moment when the editor is about to save the data, where I will display a dialog box, which says “do you want to really commit?”, clicking on yes I can call the savecellEditor.

                             

                            But my problem is say we have the following

                             

                             

                            Formatter

                            {

                                        callDialog()

                                        return something based on the dialog or the flag

                            }

                             

                             

                            callDialog()

                            {

                             

                                        handleOK {   saveCellEditor( ) or may be set a flag}

                                        handleCANCEL { do Nothing}

                             

                            }

                             

                             

                            By the time I click on the OK button of the dialog box, Formatter should have done its job of displaying the dialog box, but has nothing to return.

                             

                             

                            Thanks

                            Prasanna

                             


                            From:ydn-javascript@ yahoogroups. com [mailto: ydn-javascript@ yahoogroups. com ] On Behalf Of Satyam
                            Sent: Friday, August 17, 2007 2:21 PM
                            To: ydn-javascript@ yahoogroups. com
                            Subject: Re: [ydn-javascript] Editable datatable..

                             

                            A good place to do this would be to assign a validator function to the columns you will edit such that if the user confirms, you return the received value (first argument, newData) indicating it validated Ok, otherwise, you return null and the validation will fail. 

                             

                            See the method:

                             

                            YAHOO.widget. DataTable. prototype. saveCellEditor 

                             

                            in datatable-beta. js and you will see how it would work. I think it is the least intrusive way to do what you are asking for.  This method is called to save the data for any cell editor, whichever way the user ends the inline editing and the call to:

                             

                            this._oCellEditor. validator. call(this, newData, oldData);

                             

                            is a good place to catch the right moment.

                             

                            Satyam

                             

                             

                             

                            ----- Original Message -----

                            From:

                            (Message over 64 KB, truncated)

                          • Nagasamudram, Prasanna Kumar
                            Thanks Satyam I would also like to get the column name But for some reason the following is returning null. alert(myDataTable.getCellEditor().column.label);
                            Message 13 of 21 , Sep 4, 2007

                              Thanks Satyam

                               

                              I would also like to get the column name

                               

                              But for some reason the following is returning null.

                               

                              alert(myDataTable.getCellEditor().column.label);

                               

                               

                               

                              Thanks

                              Prasanna


                              From: ydn-javascript@yahoogroups.com [mailto: ydn-javascript@yahoogroups.com ] On Behalf Of Satyam
                              Sent: Tuesday, September 04, 2007 1:35 PM
                              To: ydn-javascript@yahoogroups.com
                              Subject: Re: [ydn-javascript] Editable datatable..

                               

                              Yes:

                               

                              MyDataTable. getCellEditor( ).record

                               

                              See:

                               

                               

                              There is a lot of information in that object.  There is only one cell editor active at a time and it contains all you could possibly care about a cell being edited.

                               

                              Satyam

                               

                              ----- Original Message -----

                              Sent: Tuesday, September 04, 2007 9:43 AM

                              Subject: RE: [ydn-javascript] Editable datatable..

                               

                              Hi Satyam

                               

                              editor:"textbox",editorOptions: {validator: function( oData){
                                   if (confirm('do you want to save?')) return oData;
                                   return null;
                                  }}

                               

                               

                              Here oData refers to the actual data. (of that particular cell).

                               

                              Is there a way to get the record from this…

                               

                              I mean I would like to send an Ajax request using the other fields in the row.

                               

                              Is there something like

                               

                              record = getRecord(oData)

                               

                              and then use record.someotherfie ld etc…

                               

                               

                              Thanks

                              Prasanna

                               


                              From: ydn-javascript@ yahoogroups. com [mailto: ydn-javascript@ yahoogroups. com ] On Behalf Of Satyam
                              Sent: Tuesday, August 28, 2007 5:44 PM
                              To: ydn-javascript@ yahoogroups. com
                              Subject: Re: [ydn-javascript] Editable datatable..

                               

                              I'm a little confused, Formatter?  that's used for displaying, I was talking about the validator.. 

                               

                              Anyway, here is a little sample code that works and I hope will explain itself, just add the following to the column definition of any column you want to have further confirmation before saving:

                               

                              editor:"textbox",editorOptions: {validator: function( oData){
                                   if (confirm('do you want to save?')) return oData;
                                   return null;
                                  }}

                               

                              Satyam

                               

                              ----- Original Message -----

                              Sent: Tuesday, August 28, 2007 1:22 PM

                              Subject: RE: [ydn-javascript] Editable datatable..

                               

                              Hi Satyam

                               

                              I was able to catch the moment when the editor is about to save the data, where I will display a dialog box, which says “do you want to really commit?”, clicking on yes I can call the savecellEditor.

                               

                              But my problem is say we have the following

                               

                               

                              Formatter

                              {

                                          callDialog()

                                          return something based on the dialog or the flag

                              }

                               

                               

                              callDialog()

                              {

                               

                                          handleOK {   saveCellEditor( ) or may be set a flag}

                                          handleCANCEL { do Nothing}

                               

                              }

                               

                               

                              By the time I click on the OK button of the dialog box, Formatter should have done its job of displaying the dialog box, but has nothing to return.

                               

                               

                              Thanks

                              Prasanna

                               


                              (Message over 64 KB, truncated)
                            • Satyam
                              You would probably want the column.key, not the label, which if null defaults to the key. The label is just for the user to see, it might even be in different
                              Message 14 of 21 , Sep 4, 2007
                                You would probably want the column.key, not the label, which if null defaults to the key.  The label is just for the user to see, it might even be in different languages, the key is your internal name for the column.
                                 
                                Satyam
                                 
                                ----- Original Message -----
                                Sent: Tuesday, September 04, 2007 11:17 AM
                                Subject: RE: [ydn-javascript] Editable datatable..

                                Thanks Satyam

                                 

                                I would also like to get the column name

                                 

                                But for some reason the following is returning null.

                                 

                                alert(myDataTable.getCellEditor().column.label);

                                 

                                 

                                 

                                Thanks

                                Prasanna


                                From: ydn-javascript@yahoogroups.com [mailto: ydn-javascript@yahoogroups.com ] On Behalf Of Satyam
                                Sent: Tuesday, September 04, 2007 1:35 PM
                                To: ydn-javascript@yahoogroups.com
                                Subject: Re: [ydn-javascript] Editable datatable..

                                 

                                Yes:

                                 

                                MyDataTable. getCellEditor( ).record

                                 

                                See:

                                 

                                 

                                There is a lot of information in that object.  There is only one cell editor active at a time and it contains all you could possibly care about a cell being edited.

                                 

                                Satyam

                                 

                                ----- Original Message -----

                                Sent: Tuesday, September 04, 2007 9:43 AM

                                Subject: RE: [ydn-javascript] Editable datatable..

                                 

                                Hi Satyam

                                 

                                editor:"textbox",editorOptions: {validator: function( oData){
                                     if (confirm('do you want to save?')) return oData;
                                     return null;
                                    }}

                                 

                                 

                                Here oData refers to the actual data. (of that particular cell).

                                 

                                Is there a way to get the record from this…

                                 

                                I mean I would like to send an Ajax request using the other fields in the row.

                                 

                                Is there something like

                                 

                                record = getRecord(oData)

                                 

                                and then use record.someotherfie ld etc…

                                 

                                 

                                Thanks

                                Prasanna

                                 


                                From:ydn-javascript@ yahoogroups. com [mailto: ydn-javascript@ yahoogroups. com ] On Behalf Of Satyam
                                Sent: Tuesday, August 28, 2007 5:44 PM
                                To: ydn-javascript@ yahoogroups. com
                                Subject: Re: [ydn-javascript] Editable datatable..

                                 

                                I'm a little confused, Formatter?  that's used for displaying, I was talking about the validator.. 

                                 

                                Anyway, here is a little sample code that works and I hope will explain itself, just add the following to the column definition of any column you want to have further confirmation before saving:

                                 

                                editor:"textbox",editorOptions: {validator: function( oData){
                                     if (confirm('do you want to save?')) return oData;
                                     return null;
                                    }}

                                 

                                Satyam

                                 

                                ----- Original Message -----

                                Sent: Tuesday, August 28, 2007 1:22 PM

                                Subject: RE: [ydn-javascript] Editable datatable..

                                 

                                Hi Satyam

                                 

                                I was able to catch the moment when the editor is about to save the data, where I will display a dialog box, which says “do you want to really commit?”, clicking on yes I can call the savecellEditor.

                                 

                                But my problem is say we have the following

                                 

                                 

                                Formatter

                                {

                                            callDialog()

                                            return something based on the dialog or the flag

                                }

                                 

                                 

                              • Nagasamudram, Prasanna Kumar
                                No I want the label.... I want to do something like If (label is aaa ) { sendAjaxrequest(myDataTable.getCellEditor().getData( param1 ), P1 ) } If(label is
                                Message 15 of 21 , Sep 4, 2007

                                  No I want the label….

                                   

                                  I want to do something like

                                   

                                  If (label is “aaa”)

                                  {

                                              sendAjaxrequest(myDataTable.getCellEditor().getData("param1"), “P1”)

                                  }

                                  If(label is “bbb”)

                                  {

                                              sendAjaxrequest(myDataTable.getCellEditor().getData("param1"), “P2”)

                                   

                                  }

                                   

                                   

                                  Well I can do this wil the internal column name for example if its column 2 do this else do that.

                                   

                                  But what if I insert another column later….I need to change the above logic again.

                                   

                                  If I compare it with the label name then the above logic remains intact, irrespective of the column position.

                                   

                                  Thanks

                                  Prasanna

                                   


                                  From: ydn-javascript@yahoogroups.com [mailto: ydn-javascript@yahoogroups.com ] On Behalf Of Satyam
                                  Sent: Tuesday, September 04, 2007 3:20 PM
                                  To: ydn-javascript@yahoogroups.com
                                  Subject: Re: [ydn-javascript] Editable datatable..

                                   

                                  You would probably want the column.key, not the label, which if null defaults to the key.  The label is just for the user to see, it might even be in different languages, the key is your internal name for the column.

                                   

                                  Satyam

                                   

                                  ----- Original Message -----

                                  Sent: Tuesday, September 04, 2007 11:17 AM

                                  Subject: RE: [ydn-javascript] Editable datatable..

                                   

                                  Thanks Satyam

                                   

                                  I would also like to get the column name

                                   

                                  But for some reason the following is returning null.

                                   

                                  alert(myDataTable. getCellEditor( ).column.label);

                                   

                                   

                                   

                                  Thanks

                                  Prasanna


                                  From: ydn-javascript@ yahoogroups. com [mailto: ydn-javascript@ yahoogroups. com ] On Behalf Of Satyam
                                  Sent: Tuesday, September 04, 2007 1:35 PM
                                  To: ydn-javascript@ yahoogroups. com
                                  Subject: Re: [ydn-javascript] Editable datatable..

                                   

                                  Yes:

                                   

                                  MyDataTable. getCellEditor( ).record

                                   

                                  See:

                                   

                                   

                                  There is a lot of information in that object.  There is only one cell editor active at a time and it contains all you could possibly care about a cell being edited.

                                   

                                  Satyam

                                   

                                  ----- Original Message -----

                                  Sent: Tuesday, September 04, 2007 9:43 AM

                                  Subject: RE: [ydn-javascript] Editable datatable..

                                   

                                  Hi Satyam

                                   

                                  editor:"textbox",editorOptions: {validator: function( oData){
                                       if (confirm('do you want to save?')) return oData;
                                       return null;
                                      }}

                                   

                                   

                                  Here oData refers to the actual data. (of that particular cell).

                                   

                                  Is there a way to get the record from this…

                                   

                                  I mean I would like to send an Ajax request using the other fields in the row.

                                   

                                  Is there something like

                                   

                                  record = getRecord(oData)

                                   

                                  and then use record.someotherfie ld etc…

                                   

                                   

                                  Thanks

                                  Prasanna

                                   


                                  From: ydn-javascript@ yahoogroups. com [mailto: ydn-javascript@ yahoogroups. com ] On Behalf Of Satyam
                                  Sent: Tuesday, August 28, 2007 5:44 PM
                                  To: ydn-javascript@ yahoogroups. com
                                  Subject: Re: [ydn-javascript] Editable datatable..

                                   

                                  I'm a little confused, Formatter?  that's used for displaying, I was talking about the validator.. 

                                   

                                  Anyway, here is a little sample code that works and I hope will explain itself, just add the following to the column definition of any column you want to have further confirmation before saving:

                                   

                                • Satyam
                                  The key is not the ordinal number of the column but the property key: something that you give the columns in the column definitions array and, for lack of
                                  Message 16 of 21 , Sep 4, 2007