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

Database InLine editing Affecting Values of other columns in Row

Expand Messages
  • daisyhmazie
    Hi! Im new using YUI and very rusty with my javascript. Im having trouble figure out how to firstly have a column that s calculated from the values of another
    Message 1 of 9 , Oct 1, 2008
    • 0 Attachment
      Hi!
      Im new using YUI and very rusty with my javascript. Im having trouble
      figure out how to firstly have a column that's calculated from the
      values of another column in the record. And secondly, when a column
      is edited, have the calculated column change it's value based on the
      new value entered.
      TIA!
      D
    • Satyam
      You can list columns in the column defs array that don t exist in the responseSchema.fields array. Those columns need to have a formatter function defined
      Message 2 of 9 , Oct 1, 2008
      • 0 Attachment
        You can list columns in the column defs array that don't exist in the
        responseSchema.fields array. Those columns need to have a formatter
        function defined because otherwise they would be empty.

        http://developer.yahoo.com/yui/datatable/#format

        The formatter function has access to all values in the record and can
        calculate the value for this extra column based on them.

        At anytime you want to refresh the value on that column, you can call
        formatCell:

        http://developer.yahoo.com/yui/docs/YAHOO.widget.DataTable.html#method_formatCell

        for example, in response to editorSaveEvent:

        http://developer.yahoo.com/yui/docs/YAHOO.widget.DataTable.html#event_editorSaveEvent

        Satyam

        daisyhmazie wrote:
        > Hi!
        > Im new using YUI and very rusty with my javascript. Im having trouble
        > figure out how to firstly have a column that's calculated from the
        > values of another column in the record. And secondly, when a column
        > is edited, have the calculated column change it's value based on the
        > new value entered.
        > TIA!
        > D
        >
        >
        > ------------------------------------
        >
        > Yahoo! Groups Links
        >
        >
        >
        > ------------------------------------------------------------------------
        >
        >
        > No virus found in this incoming message.
        > Checked by AVG - http://www.avg.com
        > Version: 8.0.169 / Virus Database: 270.7.5/1702 - Release Date: 01/10/2008 9:05
        >
        >
      • Donna Lanasa
        ok, so I have the field computing on the first render of the table, but after I text edit another column in that row and call editorSaveEvent, I can access the
        Message 3 of 9 , Oct 2, 2008
        • 0 Attachment
          ok, so I have the field computing on the first render of the table,
          but after I text edit another column in that row and call editorSaveEvent,
          I can access the values for all the columns except the one that was computed.
          I get 'undefined'.  It seems like tha value is not being saved...  What am I doing wrong?

          Thx
          D
          ----- Original Message ----
          From: Satyam <satyam@...>
          To: ydn-javascript@yahoogroups.com
          Sent: Wednesday, October 1, 2008 11:21:14 PM
          Subject: Re: [ydn-javascript] Database InLine editing Affecting Values of other columns in Row

          You can list columns in the column defs array that don't exist in the
          responseSchema. fields array. Those columns need to have a formatter
          function defined because otherwise they would be empty.

          http://developer. yahoo.com/ yui/datatable/ #format

          The formatter function has access to all values in the record and can
          calculate the value for this extra column based on them.

          At anytime you want to refresh the value on that column, you can call
          formatCell:

          http://developer. yahoo.com/ yui/docs/ YAHOO.widget. DataTable. html#method_ formatCell

          for example, in response to editorSaveEvent:

          http://developer. yahoo.com/ yui/docs/ YAHOO.widget. DataTable. html#event_ editorSaveEvent

          Satyam

          daisyhmazie wrote:

          > Hi!
          > Im new using YUI and very rusty with my javascript. Im having trouble
          > figure out how to firstly have a column that's calculated from the
          > values of another column in the record. And secondly, when a column
          > is edited, have the calculated column change it's value based on the
          > new value entered.
          > TIA!
          > D
          >
          >
          > ------------ --------- --------- ------
          >
          > Yahoo! Groups Links
          >
          >
          >
          > ------------ --------- --------- --------- --------- --------- -
          >
          >
          > No virus found in this incoming message.
          > Checked by AVG - http://www.avg. com
          > Version: 8.0.169 / Virus Database: 270.7.5/1702 - Release Date: 01/10/2008 9:05
          >
          >


        • Satyam
          The value would never be stored, it would only be displayed. By assigning a formatter, you would get the cell in the table filled with a calculated value, but
          Message 4 of 9 , Oct 2, 2008
          • 0 Attachment
            The value would never be stored, it would only be displayed. By
            assigning a formatter, you would get the cell in the table filled with a
            calculated value, but it would not get stored elsewhere, it doesn't need
            to, anyway. In editorSaveEvent just call formatCell on the cell with
            the calculated value, that would force a recalculation of that cell
            based on the values of the other fields in the record, just as the first
            time around.

            Satyam

            Donna Lanasa wrote:
            > ok, so I have the field computing on the first render of the table,
            > but after I text edit another column in that row and call editorSaveEvent,
            > I can access the values for all the columns except the one that was
            > computed.
            > I get 'undefined'. It seems like tha value is not being saved...
            > What am I doing wrong?
            >
            > Thx
            > D
            > ----- Original Message ----
            > From: Satyam <satyam@...>
            > To: ydn-javascript@yahoogroups.com
            > Sent: Wednesday, October 1, 2008 11:21:14 PM
            > Subject: Re: [ydn-javascript] Database InLine editing Affecting Values
            > of other columns in Row
            >
            > You can list columns in the column defs array that don't exist in the
            > responseSchema. fields array. Those columns need to have a formatter
            > function defined because otherwise they would be empty.
            >
            > http://developer. yahoo.com/ yui/datatable/ #format
            > <http://developer.yahoo.com/yui/datatable/#format>
            >
            > The formatter function has access to all values in the record and can
            > calculate the value for this extra column based on them.
            >
            > At anytime you want to refresh the value on that column, you can call
            > formatCell:
            >
            > http://developer. yahoo.com/ yui/docs/ YAHOO.widget. DataTable.
            > html#method_ formatCell
            > <http://developer.yahoo.com/yui/docs/YAHOO.widget.DataTable.html#method_formatCell>
            >
            > for example, in response to editorSaveEvent:
            >
            > http://developer. yahoo.com/ yui/docs/ YAHOO.widget. DataTable.
            > html#event_ editorSaveEvent
            > <http://developer.yahoo.com/yui/docs/YAHOO.widget.DataTable.html#event_editorSaveEvent>
            >
            > Satyam
            >
            > daisyhmazie wrote:
            > > Hi!
            > > Im new using YUI and very rusty with my javascript. Im having trouble
            > > figure out how to firstly have a column that's calculated from the
            > > values of another column in the record. And secondly, when a column
            > > is edited, have the calculated column change it's value based on the
            > > new value entered.
            > > TIA!
            > > D
            > >
            > >
            > > ------------ --------- --------- ------
            > >
            > > Yahoo! Groups Links
            > >
            > >
            > >
            > > ------------ --------- --------- --------- --------- --------- -
            > >
            > >
            > > No virus found in this incoming message.
            > > Checked by AVG - http://www.avg. com <http://www.avg.com>
            > > Version: 8.0.169 / Virus Database: 270.7.5/1702 - Release Date:
            > 01/10/2008 9:05
            > >
            > >
            >
            >
            >
            > ------------------------------------------------------------------------
            >
            >
            > No virus found in this incoming message.
            > Checked by AVG - http://www.avg.com
            > Version: 8.0.173 / Virus Database: 270.7.5/1703 - Release Date: 02/10/2008 7:46
            >
            >
          • Donna Lanasa
            ok this is a really stupid question, but when I call formatCell, how do I specifically assign the new value to the calculated Column? ... From: Satyam
            Message 5 of 9 , Oct 2, 2008
            • 0 Attachment
              ok this is a really stupid question, but when I call formatCell, how do I specifically
              assign the new value to the calculated  Column?

              ----- Original Message ----
              From: Satyam <satyam@...>
              To: ydn-javascript@yahoogroups.com
              Sent: Thursday, October 2, 2008 2:37:49 PM
              Subject: Re: [ydn-javascript] Database InLine editing Affecting Values of other columns in Row

              The value would never be stored, it would only be displayed. By
              assigning a formatter, you would get the cell in the table filled with a
              calculated value, but it would not get stored elsewhere, it doesn't need
              to, anyway. In editorSaveEvent just call formatCell on the cell with
              the calculated value, that would force a recalculation of that cell
              based on the values of the other fields in the record, just as the first
              time around.

              Satyam

              Donna Lanasa wrote:

              > ok, so I have the field computing on the first render of the table,
              > but after I text edit another column in that row and call editorSaveEvent,
              > I can access the values for all the columns except the one that was
              > computed.
              > I get 'undefined'. It seems like tha value is not being saved...
              > What am I doing wrong?
              >
              > Thx
              > D
              > ----- Original Message ----
              > From: Satyam <satyam@satyam. com.ar>
              > To: ydn-javascript@ yahoogroups. com
              > Sent: Wednesday, October 1, 2008 11:21:14 PM
              > Subject: Re: [ydn-javascript] Database InLine editing Affecting Values
              > of other columns in Row
              >
              > You can list columns in the column defs array that don't exist in the
              > responseSchema. fields array. Those columns need to have a formatter
              > function defined because otherwise they would be empty.
              >
              > http://developer. yahoo.com/ yui/datatable/ #format
              > <http://developer. yahoo.com/ yui/datatable/ #format>
              >
              > The formatter function has access to all values in the record and can
              > calculate the value for this extra column based on them.
              >
              > At anytime you want to refresh the value on that column, you can call
              > formatCell:
              >
              > http://developer. yahoo.com/ yui/docs/ YAHOO.widget. DataTable.
              > html#method_ formatCell
              > <http://developer. yahoo.com/ yui/docs/ YAHOO.widget. DataTable. html#method_ formatCell>
              >
              > for example, in response to editorSaveEvent:
              >
              > http://developer. yahoo.com/ yui/docs/ YAHOO.widget. DataTable.
              > html#event_ editorSaveEvent
              > <http://developer. yahoo.com/ yui/docs/ YAHOO.widget. DataTable. html#event_ editorSaveEvent>
              >
              > Satyam
              >
              > daisyhmazie wrote:
              > > Hi!
              > > Im new using YUI and very rusty with my javascript. Im having trouble
              > > figure out how to firstly have a column that's calculated from the
              > > values of another column in the record. And secondly, when a column
              > > is edited, have the calculated column change it's value based on the
              > > new value entered.
              > > TIA!
              > > D
              > >
              > >
              > > ------------ --------- --------- ------
              > >
              > > Yahoo! Groups Links
              > >
              > >
              > >
              > > ------------ --------- --------- --------- --------- --------- -
              > >
              > >
              > > No virus found in this incoming message.
              > > Checked by AVG - http://www.avg. com <http://www.avg. com>
              > > Version: 8.0.169 / Virus Database: 270.7.5/1702 - Release Date:
              > 01/10/2008 9:05
              > >
              > >
              >
              >
              >
              > ------------ --------- --------- --------- --------- --------- -
              >
              >
              > No virus found in this incoming message.
              > Checked by AVG - http://www.avg. com
              > Version: 8.0.173 / Virus Database: 270.7.5/1703 - Release Date: 02/10/2008 7:46
              >
              >


            • Satyam
              You don t. The formatter function does the calculation just as the first time. When you call formatCell, it will eventually call your formatter function
              Message 6 of 9 , Oct 3, 2008
              • 0 Attachment
                You don't. The formatter function does the calculation just as the
                first time. When you call formatCell, it will eventually call your
                formatter function which picks the values of the other fields in the
                record and does the calculation once again.

                Satyam


                Donna Lanasa wrote:
                > ok this is a really stupid question, but when I call formatCell, how
                > do I specifically
                > assign the new value to the calculated Column?
                >
                > ----- Original Message ----
                > From: Satyam <satyam@...>
                > To: ydn-javascript@yahoogroups.com
                > Sent: Thursday, October 2, 2008 2:37:49 PM
                > Subject: Re: [ydn-javascript] Database InLine editing Affecting Values
                > of other columns in Row
                >
                > The value would never be stored, it would only be displayed. By
                > assigning a formatter, you would get the cell in the table filled with a
                > calculated value, but it would not get stored elsewhere, it doesn't need
                > to, anyway. In editorSaveEvent just call formatCell on the cell with
                > the calculated value, that would force a recalculation of that cell
                > based on the values of the other fields in the record, just as the first
                > time around.
                >
                > Satyam
                >
                > Donna Lanasa wrote:
                > > ok, so I have the field computing on the first render of the table,
                > > but after I text edit another column in that row and call
                > editorSaveEvent,
                > > I can access the values for all the columns except the one that was
                > > computed.
                > > I get 'undefined'. It seems like tha value is not being saved...
                > > What am I doing wrong?
                > >
                > > Thx
                > > D
                > > ----- Original Message ----
                > > From: Satyam <satyam@satyam. com.ar <mailto:satyam%40satyam.com.ar>>
                > > To: ydn-javascript@ yahoogroups. com
                > <mailto:ydn-javascript%40yahoogroups.com>
                > > Sent: Wednesday, October 1, 2008 11:21:14 PM
                > > Subject: Re: [ydn-javascript] Database InLine editing Affecting Values
                > > of other columns in Row
                > >
                > > You can list columns in the column defs array that don't exist in the
                > > responseSchema. fields array. Those columns need to have a formatter
                > > function defined because otherwise they would be empty.
                > >
                > > http://developer. yahoo.com/ <http://yahoo.com/> yui/datatable/ #format
                > > <http://developer. yahoo.com/ yui/datatable/ #format
                > <http://developer.yahoo.com/yui/datatable/#format>>
                > >
                > > The formatter function has access to all values in the record and can
                > > calculate the value for this extra column based on them.
                > >
                > > At anytime you want to refresh the value on that column, you can call
                > > formatCell:
                > >
                > > http://developer. yahoo.com/ yui/docs/ YAHOO.widget. DataTable.
                > > html#method_ formatCell
                > > <http://developer. yahoo.com/ yui/docs/ YAHOO.widget. DataTable.
                > html#method_ formatCell
                > <http://developer.yahoo.com/yui/docs/YAHOO.widget.DataTable.html#method_formatCell>>
                > >
                > > for example, in response to editorSaveEvent:
                > >
                > > http://developer. yahoo.com/ yui/docs/ YAHOO.widget. DataTable.
                > > html#event_ editorSaveEvent
                > > <http://developer. yahoo.com/ yui/docs/ YAHOO.widget. DataTable.
                > html#event_ editorSaveEvent
                > <http://developer.yahoo.com/yui/docs/YAHOO.widget.DataTable.html#event_editorSaveEvent>>
                > >
                > > Satyam
                > >
                > > daisyhmazie wrote:
                > > > Hi!
                > > > Im new using YUI and very rusty with my javascript. Im having trouble
                > > > figure out how to firstly have a column that's calculated from the
                > > > values of another column in the record. And secondly, when a column
                > > > is edited, have the calculated column change it's value based on the
                > > > new value entered.
                > > > TIA!
                > > > D
                > > >
                > > >
                > > > ------------ --------- --------- ------
                > > >
                > > > Yahoo! Groups Links
                > > >
                > > >
                > > >
                > > > ------------ --------- --------- --------- --------- --------- -
                > > >
                > > >
                > > > No virus found in this incoming message.
                > > > Checked by AVG - http://www.avg. com <http://www.avg. com
                > <http://www.avg.com>>
                > > > Version: 8.0.169 / Virus Database: 270.7.5/1702 - Release Date:
                > > 01/10/2008 9:05
                > > >
                > > >
                > >
                > >
                > >
                > > ------------ --------- --------- --------- --------- --------- -
                > >
                > >
                > > No virus found in this incoming message.
                > > Checked by AVG - http://www.avg. com <http://www.avg.com>
                > > Version: 8.0.173 / Virus Database: 270.7.5/1703 - Release Date:
                > 02/10/2008 7:46
                > >
                > >
                >
                >
                >
                > ------------------------------------------------------------------------
                >
                >
                > No virus found in this incoming message.
                > Checked by AVG - http://www.avg.com
                > Version: 8.0.173 / Virus Database: 270.7.5/1703 - Release Date: 02/10/2008 7:46
                >
                >
              • Donna Lanasa
                hmm that was one of the things I tried but I must be doing something wrong because the alerts I have in the formatCell function get called when I first load
                Message 7 of 9 , Oct 3, 2008
                • 0 Attachment
                  hmm that was one of the things I tried but I must be doing something wrong because the
                  alerts I have in the formatCell function get called when I first load the page but then after I edit
                  the firtNum field, the formatCell function doesnt get called
                  again because the value of the second field  doesnt change and the alerts are never triggered.

                  What am I doing wrong?
                  TIA

                  (function () {
                      var loader = new YAHOO.util.YUILoader();
                      loader.loadOptional = true;
                      loader.require("reset-fonts-grids","base","datatable","dragdrop","selector");
                      loader.insert({
                          onSuccess: function() {
                              //shortcuts
                              var $C = YAHOO.util.Connect,
                                  $E = YAHOO.util.Event,
                                  $D = YAHOO.util.Dom,
                                  $L = YAHOO.lang,
                                  $ = $D.get,
                                  $DT = YAHOO.widget.DataTable;
                                  $DT.prototype.refreshRow = function(row) {
                                      var $D = YAHOO.util.Dom;
                                      $D.batch($D.getChildren(this.getTrEl(row)),this.formatCell,this,true);};           
                              $DT.formatCell = function(elCell, oRecord, oColumn){
                                  alert("FORMAT CELL:" + oRecord.getData("firstNum"));   
                                  elCell.innerHTML = (oRecord.getData("firstNum") +5);
                                  alert(elCell.innerHTML)
                              }


                              // This is just for the sample SSN example described below.
                              var dtSSN = new $DT(
                                  'theContainer',
                                  [{
                                      key:'firstNum',
                                      formatter:$DT.formatNumber,
                                      editor:"textbox"
                                      },
                                  {key:'secondNum',formatter:$DT.formatCell}                    
                                  ],new YAHOO.util.DataSource(
                                      [{firstNum:12}],
                                      {
                                      responseType:YAHOO.util.DataSource.TYPE_JSARRAY,
                                      responseSchema: {fields:['firstNum']}
                                      })
                                  );
                                 
                                  dtSSN.subscribe('cellClickEvent', dtSSN.onEventShowCellEditor);
                                  dtSSN.subscribe('editorSaveEvent',$DT.formatCell)

                          }       
                      });
                  })();

                  From: Satyam <satyam@...>
                  To: ydn-javascript@yahoogroups.com
                  Sent: Friday, October 3, 2008 8:19:31 AM
                  Subject: Re: [ydn-javascript] Database InLine editing Affecting Values of other columns in Row

                  You don't. The formatter function does the calculation just as the
                  first time. When you call formatCell, it will eventually call your
                  formatter function which picks the values of the other fields in the
                  record and does the calculation once again.

                  Satyam

                  Donna Lanasa wrote:

                  > ok this is a really stupid question, but when I call formatCell, how
                  > do I specifically
                  > assign the new value to the calculated Column?
                  >
                  > ----- Original Message ----
                  > From: Satyam <satyam@satyam. com.ar>
                  > To: ydn-javascript@ yahoogroups. com
                  > Sent: Thursday, October 2, 2008 2:37:49 PM
                  > Subject: Re: [ydn-javascript] Database InLine editing Affecting Values
                  > of other columns in Row
                  >
                  > The value would never be stored, it would only be displayed. By
                  > assigning a formatter, you would get the cell in the table filled with a
                  > calculated value, but it would not get stored elsewhere, it doesn't need
                  > to, anyway. In editorSaveEvent just call formatCell on the cell with
                  > the calculated value, that would force a recalculation of that cell
                  > based on the values of the other fields in the record, just as the first
                  > time around.
                  >
                  > Satyam
                  >
                  > Donna Lanasa wrote:
                  > > ok, so I have the field computing on the first render of the table,
                  > > but after I text edit another column in that row and call
                  > editorSaveEvent,
                  > > I can access the values for all the columns except the one that was
                  > > computed.
                  > > I get 'undefined'. It seems like tha value is not being saved...
                  > > What am I doing wrong?
                  > >
                  > > Thx
                  > > D
                  > > ----- Original Message ----
                  > > From: Satyam <satyam@satyam. com.ar <mailto:satyam% 40satyam. com.ar>>
                  > > To: ydn-javascript@ yahoogroups. com
                  > <mailto:ydn- javascript% 40yahoogroups. com>
                  > > Sent: Wednesday, October 1, 2008 11:21:14 PM
                  > > Subject: Re: [ydn-javascript] Database InLine editing Affecting Values
                  > > of other columns in Row
                  > >
                  > > You can list columns in the column defs array that don't exist in the
                  > > responseSchema. fields array. Those columns need to have a formatter
                  > > function defined because otherwise they would be empty.
                  > >
                  > > http://developer. yahoo.com/ <http://yahoo. com/> yui/datatable/ #format
                  > > <http://developer. yahoo.com/ yui/datatable/ #format
                  > <http://developer. yahoo.com/ yui/datatable/ #format>>
                  > >
                  > > The formatter function has access to all values in the record and can
                  > > calculate the value for this extra column based on them.
                  > >
                  > > At anytime you want to refresh the value on that column, you can call
                  > > formatCell:
                  > >
                  > > http://developer. yahoo.com/ yui/docs/ YAHOO.widget. DataTable.
                  > > html#method_ formatCell
                  > > <http://developer. yahoo.com/ yui/docs/ YAHOO.widget. DataTable.
                  > html#method_ formatCell
                  > <http://developer. yahoo.com/ yui/docs/ YAHOO.widget. DataTable. html#method_ formatCell>>
                  > >
                  > > for example, in response to editorSaveEvent:
                  > >
                  > > http://developer. yahoo.com/ yui/docs/ YAHOO.widget. DataTable.
                  > > html#event_ editorSaveEvent
                  > > <http://developer. yahoo.com/ yui/docs/ YAHOO.widget. DataTable.
                  > html#event_ editorSaveEvent
                  > <http://developer. yahoo.com/ yui/docs/ YAHOO.widget. DataTable. html#event_ editorSaveEvent>>
                  > >
                  > > Satyam
                  > >
                  > > daisyhmazie wrote:
                  > > > Hi!
                  > > > Im new using YUI and very rusty with my javascript. Im having trouble
                  > > > figure out how to firstly have a column that's calculated from the
                  > > > values of another column in the record. And secondly, when a column
                  > > > is edited, have the calculated column change it's value based on the
                  > > > new value entered.
                  > > > TIA!
                  > > > D
                  > > >
                  > > >
                  > > > ------------ --------- --------- ------
                  > > >
                  > > > Yahoo! Groups Links
                  > > >
                  > > >
                  > > >
                  > > > ------------ --------- --------- --------- --------- --------- -
                  > > >
                  > > >
                  > > > No virus found in this incoming message.
                  > > > Checked by AVG - http://www.avg. com <http://www.avg. com
                  > <http://www.avg. com>>
                  > > > Version: 8.0.169 / Virus Database: 270.7.5/1702 - Release Date:
                  > > 01/10/2008 9:05
                  > > >
                  > > >
                  > >
                  > >
                  > >
                  > > ------------ --------- --------- --------- --------- --------- -
                  > >
                  > >
                  > > No virus found in this incoming message.
                  > > Checked by AVG - http://www.avg. com <http://www.avg. com>
                  > > Version: 8.0.173 / Virus Database: 270.7.5/1703 - Release Date:
                  > 02/10/2008 7:46
                  > >
                  > >
                  >
                  >
                  >
                  > ------------ --------- --------- --------- --------- --------- -
                  >
                  >
                  > No virus found in this incoming message.
                  > Checked by AVG - http://www.avg. com
                  > Version: 8.0.173 / Virus Database: 270.7.5/1703 - Release Date: 02/10/2008 7:46
                  >
                  >


                • Satyam
                  I m not sure how the code below is related to your issue, they are bits and pieces from some examples of mine (which you are not using) plus some code of your
                  Message 8 of 9 , Oct 4, 2008
                  • 0 Attachment
                    I'm not sure how the code below is related to your issue, they are bits
                    and pieces from some examples of mine (which you are not using) plus
                    some code of your own.

                    Method refreshRow does not work any longer as it is. That piece of code
                    has not worked since 2.5. Anyway, you are not using it.

                    You are defining a static formatCell function as part of the basic
                    DataTable itself. It won't collide with the formatCell method but there
                    is no point in storing it there, it may turn confusing to have an
                    instance method and a static method with the same name and different
                    functionality on the same object.

                    I did say that in response to editorSaveEvent you could call
                    formatCell. I meant "eventually call formatCell", the original one not
                    one you make and not directly, the arguments don't match, they are not
                    related and by calling your own function formatCell, things don't get
                    improved at all, they just confuse things.

                    This one works, and I've put two options there (and provided the fixed
                    refreshRow):

                    (function () {
                    var loader = new YAHOO.util.YUILoader();
                    loader.loadOptional = true;
                    loader.require("reset-fonts-grids","base","datatable","dragdrop","selector");
                    loader.insert({
                    onSuccess: function() {
                    //shortcuts
                    var $C = YAHOO.util.Connect,
                    $E = YAHOO.util.Event,
                    $D = YAHOO.util.Dom,
                    $L = YAHOO.lang,
                    $ = $D.get,
                    $DT = YAHOO.widget.DataTable;
                    $DT.prototype.refreshRow = function(row) {
                    var $D = YAHOO.util.Dom;
                    $D.batch($D.getChildren(this.getTrEl(row)),
                    function(el) {
                    this.formatCell(el.firstChild);
                    },this,true
                    );
                    };
                    var myFormatter = function(elCell, oRecord, oColumn){
                    alert("FORMAT CELL:" + oRecord.getData("firstNum"));
                    elCell.innerHTML = (oRecord.getData("firstNum") +5);
                    alert(elCell.innerHTML)
                    };


                    var dtSSN = new $DT(
                    'theContainer',
                    [{
                    key:'firstNum',
                    formatter:$DT.formatNumber,
                    editor:"textbox"
                    },
                    {key:'secondNum',formatter:myFormatter}
                    ],new YAHOO.util.DataSource(
                    [{firstNum:12}],
                    {
                    responseType:YAHOO.util.DataSource.TYPE_JSARRAY,
                    responseSchema: {fields:['firstNum']}
                    })
                    );

                    dtSSN.subscribe('cellClickEvent', dtSSN.onEventShowCellEditor);
                    dtSSN.subscribe('editorSaveEvent',function(oArgs) {
                    // either:
                    this.refreshRow(oArgs.editor.getTdEl());
                    // or:
                    this.formatCell(oArgs.editor.getTdEl().nextSibling.firstChild);
                    });
                    }
                    });
                    })();


                    Notice you have to choose one of the above, the second is the fastest
                    since it refreshes just one cell though it relies on on cell being the
                    nextSibling of the other, if you change the table layout, you will have
                    to get the cell somehow.

                    Satyam


                    Donna Lanasa wrote:
                    > hmm that was one of the things I tried but I must be doing something
                    > wrong because the
                    > alerts I have in the formatCell function get called when I first load
                    > the page but then after I edit
                    > the firtNum field, the formatCell function doesnt get called
                    > again because the value of the second field doesnt change and the
                    > alerts are never triggered.
                    >
                    > What am I doing wrong?
                    > TIA
                    >
                    > (function () {
                    > var loader = new YAHOO.util.YUILoader();
                    > loader.loadOptional = true;
                    >
                    > loader.require("reset-fonts-grids","base","datatable","dragdrop","selector");
                    > loader.insert({
                    > onSuccess: function() {
                    > //shortcuts
                    > var $C = YAHOO.util.Connect,
                    > $E = YAHOO.util.Event,
                    > $D = YAHOO.util.Dom,
                    > $L = YAHOO.lang,
                    > $ = $D.get,
                    > $DT = YAHOO.widget.DataTable;
                    > $DT.prototype.refreshRow = function(row) {
                    > var $D = YAHOO.util.Dom;
                    >
                    > $D.batch($D.getChildren(this.getTrEl(row)),this.formatCell,this,true);};
                    >
                    > $DT.formatCell = function(elCell, oRecord, oColumn){
                    > alert("FORMAT CELL:" + oRecord.getData("firstNum"));
                    > elCell.innerHTML = (oRecord.getData("firstNum") +5);
                    > alert(elCell.innerHTML)
                    > }
                    >
                    >
                    > // This is just for the sample SSN example described below.
                    > var dtSSN = new $DT(
                    > 'theContainer',
                    > [{
                    > key:'firstNum',
                    > formatter:$DT.formatNumber,
                    > editor:"textbox"
                    > },
                    > {key:'secondNum',formatter:$DT.formatCell}
                    >
                    > ],new YAHOO.util.DataSource(
                    > [{firstNum:12}],
                    > {
                    > responseType:YAHOO.util.DataSource.TYPE_JSARRAY,
                    > responseSchema: {fields:['firstNum']}
                    > })
                    > );
                    >
                    > dtSSN.subscribe('cellClickEvent',
                    > dtSSN.onEventShowCellEditor);
                    > dtSSN.subscribe('editorSaveEvent',$DT.formatCell)
                    >
                    > }
                    > });
                    > })();
                    >
                    > From: Satyam <satyam@...>
                    > To: ydn-javascript@yahoogroups.com
                    > Sent: Friday, October 3, 2008 8:19:31 AM
                    > Subject: Re: [ydn-javascript] Database InLine editing Affecting Values
                    > of other columns in Row
                    >
                    > You don't. The formatter function does the calculation just as the
                    > first time. When you call formatCell, it will eventually call your
                    > formatter function which picks the values of the other fields in the
                    > record and does the calculation once again.
                    >
                    > Satyam
                    >
                    > Donna Lanasa wrote:
                    > > ok this is a really stupid question, but when I call formatCell, how
                    > > do I specifically
                    > > assign the new value to the calculated Column?
                    > >
                    > > ----- Original Message ----
                    > > From: Satyam <satyam@satyam. com.ar <mailto:satyam%40satyam.com.ar>>
                    > > To: ydn-javascript@ yahoogroups. com
                    > <mailto:ydn-javascript%40yahoogroups.com>
                    > > Sent: Thursday, October 2, 2008 2:37:49 PM
                    > > Subject: Re: [ydn-javascript] Database InLine editing Affecting Values
                    > > of other columns in Row
                    > >
                    > > The value would never be stored, it would only be displayed. By
                    > > assigning a formatter, you would get the cell in the table filled with a
                    > > calculated value, but it would not get stored elsewhere, it doesn't need
                    > > to, anyway. In editorSaveEvent just call formatCell on the cell with
                    > > the calculated value, that would force a recalculation of that cell
                    > > based on the values of the other fields in the record, just as the first
                    > > time around.
                    > >
                    > > Satyam
                    > >
                    > > Donna Lanasa wrote:
                    > > > ok, so I have the field computing on the first render of the table,
                    > > > but after I text edit another column in that row and call
                    > > editorSaveEvent,
                    > > > I can access the values for all the columns except the one that was
                    > > > computed.
                    > > > I get 'undefined'. It seems like tha value is not being saved...
                    > > > What am I doing wrong?
                    > > >
                    > > > Thx
                    > > > D
                    > > > ----- Original Message ----
                    > > > From: Satyam <satyam@satyam. com.ar <http://com.ar>
                    > <mailto:satyam% 40satyam. com.ar>>
                    > > > To: ydn-javascript@ yahoogroups. com
                    > > <mailto:ydn- javascript% 40yahoogroups. com>
                    > > > Sent: Wednesday, October 1, 2008 11:21:14 PM
                    > > > Subject: Re: [ydn-javascript] Database InLine editing Affecting Values
                    > > > of other columns in Row
                    > > >
                    > > > You can list columns in the column defs array that don't exist in the
                    > > > responseSchema. fields array. Those columns need to have a formatter
                    > > > function defined because otherwise they would be empty.
                    > > >
                    > > > http://developer. yahoo.com/ <http://yahoo.com/> <http://yahoo.
                    > com/ <http://yahoo.com/>> yui/datatable/ #format
                    > > > <http://developer. yahoo.com/ yui/datatable/ #format
                    > > <http://developer. yahoo.com/ yui/datatable/ #format
                    > <http://developer.yahoo.com/yui/datatable/#format>>>
                    > > >
                    > > > The formatter function has access to all values in the record and can
                    > > > calculate the value for this extra column based on them.
                    > > >
                    > > > At anytime you want to refresh the value on that column, you can call
                    > > > formatCell:
                    > > >
                    > > > http://developer. yahoo.com/ yui/docs/ YAHOO.widget. DataTable.
                    > > > html#method_ formatCell
                    > > > <http://developer. yahoo.com/ yui/docs/ YAHOO.widget. DataTable.
                    > > html#method_ formatCell
                    > > <http://developer. yahoo.com/ yui/docs/ YAHOO.widget. DataTable.
                    > html#method_ formatCell
                    > <http://developer.yahoo.com/yui/docs/YAHOO.widget.DataTable.html#method_formatCell>>>
                    > > >
                    > > > for example, in response to editorSaveEvent:
                    > > >
                    > > > http://developer. yahoo.com/ yui/docs/ YAHOO.widget. DataTable.
                    > > > html#event_ editorSaveEvent
                    > > > <http://developer. yahoo.com/ yui/docs/ YAHOO.widget. DataTable.
                    > > html#event_ editorSaveEvent
                    > > <http://developer. yahoo.com/ yui/docs/ YAHOO.widget. DataTable.
                    > html#event_ editorSaveEvent
                    > <http://developer.yahoo.com/yui/docs/YAHOO.widget.DataTable.html#event_editorSaveEvent>>>
                    > > >
                    > > > Satyam
                    > > >
                    > > > daisyhmazie wrote:
                    > > > > Hi!
                    > > > > Im new using YUI and very rusty with my javascript. Im having
                    > trouble
                    > > > > figure out how to firstly have a column that's calculated from the
                    > > > > values of another column in the record. And secondly, when a column
                    > > > > is edited, have the calculated column change it's value based on the
                    > > > > new value entered.
                    > > > > TIA!
                    > > > > D
                    > > > >
                    > > > >
                    > > > > ------------ --------- --------- ------
                    > > > >
                    > > > > Yahoo! Groups Links
                    > > > >
                    > > > >
                    > > > >
                    > > > > ------------ --------- --------- --------- --------- --------- -
                    > > > >
                    > > > >
                    > > > > No virus found in this incoming message.
                    > > > > Checked by AVG - http://www.avg. com <http://www.avg. com
                    > > <http://www.avg. com <http://www.avg.com>>>
                    > > > > Version: 8.0.169 / Virus Database: 270.7.5/1702 - Release Date:
                    > > > 01/10/2008 9:05
                    > > > >
                    > > > >
                    > > >
                    > > >
                    > > >
                    > > > ------------ --------- --------- --------- --------- --------- -
                    > > >
                    > > >
                    > > > No virus found in this incoming message.
                    > > > Checked by AVG - http://www.avg. com <http://www.avg. com
                    > <http://www.avg.com>>
                    > > > Version: 8.0.173 / Virus Database: 270.7.5/1703 - Release Date:
                    > > 02/10/2008 7:46
                    > > >
                    > > >
                    > >
                    > >
                    > >
                    > > ------------ --------- --------- --------- --------- --------- -
                    > >
                    > >
                    > > No virus found in this incoming message.
                    > > Checked by AVG - http://www.avg. com <http://www.avg.com>
                    > > Version: 8.0.173 / Virus Database: 270.7.5/1703 - Release Date:
                    > 02/10/2008 7:46
                    > >
                    > >
                    >
                    >
                    >
                    > ------------------------------------------------------------------------
                    >
                    >
                    > No virus found in this incoming message.
                    > Checked by AVG - http://www.avg.com
                    > Version: 8.0.173 / Virus Database: 270.7.5/1703 - Release Date: 02/10/2008 7:46
                    >
                    >
                  • daisyhmazie@yahoo.com
                    Thanks so much! I ll try this D Sent via BlackBerry from T-Mobile ... From: Satyam Date: Sat, 04 Oct 2008 10:25:49 To:
                    Message 9 of 9 , Oct 4, 2008
                    • 0 Attachment
                      Thanks so much! I'll try this
                      D

                      Sent via BlackBerry from T-Mobile


                      From: Satyam <satyam@...>
                      Date: Sat, 04 Oct 2008 10:25:49 +0200
                      To: <ydn-javascript@yahoogroups.com>
                      Subject: Re: [ydn-javascript] Database InLine editing Affecting Values of other columns in Row

                      I'm not sure how the code below is related to your issue, they are bits
                      and pieces from some examples of mine (which you are not using) plus
                      some code of your own.

                      Method refreshRow does not work any longer as it is. That piece of code
                      has not worked since 2.5. Anyway, you are not using it.

                      You are defining a static formatCell function as part of the basic
                      DataTable itself. It won't collide with the formatCell method but there
                      is no point in storing it there, it may turn confusing to have an
                      instance method and a static method with the same name and different
                      functionality on the same object.

                      I did say that in response to editorSaveEvent you could call
                      formatCell. I meant "eventually call formatCell", the original one not
                      one you make and not directly, the arguments don't match, they are not
                      related and by calling your own function formatCell, things don't get
                      improved at all, they just confuse things.

                      This one works, and I've put two options there (and provided the fixed
                      refreshRow):

                      (function () {
                      var loader = new YAHOO.util.YUILoade r();
                      loader.loadOptional = true;
                      loader.require( "reset-fonts- grids","base" ,"datatable" ,"dragdrop" ,"selector" );
                      loader.insert( {
                      onSuccess: function() {
                      //shortcuts
                      var $C = YAHOO.util.Connect,
                      $E = YAHOO.util.Event,
                      $D = YAHOO.util.Dom,
                      $L = YAHOO.lang,
                      $ = $D.get,
                      $DT = YAHOO.widget. DataTable;
                      $DT.prototype. refreshRow = function(row) {
                      var $D = YAHOO.util.Dom;
                      $D.batch($D. getChildren( this.getTrEl( row)),
                      function(el) {
                      this.formatCell( el.firstChild) ;
                      },this,true
                      );
                      };
                      var myFormatter = function(elCell, oRecord, oColumn){
                      alert("FORMAT CELL:" + oRecord.getData( "firstNum" ));
                      elCell.innerHTML = (oRecord.getData( "firstNum" ) +5);
                      alert(elCell. innerHTML)
                      };

                      var dtSSN = new $DT(
                      'theContainer' ,
                      [{
                      key:'firstNum' ,
                      formatter:$DT. formatNumber,
                      editor:"textbox"
                      },
                      {key:'secondNum' ,formatter: myFormatter}
                      ],new YAHOO.util.DataSour ce(
                      [{firstNum:12} ],
                      {
                      responseType: YAHOO.util. DataSource. TYPE_JSARRAY,
                      responseSchema: {fields:['firstNum' ]}
                      })
                      );

                      dtSSN.subscribe( 'cellClickEvent' , dtSSN.onEventShowCe llEditor) ;
                      dtSSN.subscribe( 'editorSaveEvent ',function( oArgs) {
                      // either:
                      this.refreshRow( oArgs.editor. getTdEl() );
                      // or:
                      this.formatCell( oArgs.editor. getTdEl() .nextSibling. firstChild) ;
                      });
                      }
                      });
                      })();

                      Notice you have to choose one of the above, the second is the fastest
                      since it refreshes just one cell though it relies on on cell being the
                      nextSibling of the other, if you change the table layout, you will have
                      to get the cell somehow.

                      Satyam

                      Donna Lanasa wrote:

                      > hmm that was one of the things I tried but I must be doing something
                      > wrong because the
                      > alerts I have in the formatCell function get called when I first load
                      > the page but then after I edit
                      > the firtNum field, the formatCell function doesnt get called
                      > again because the value of the second field doesnt change and the
                      > alerts are never triggered.
                      >
                      > What am I doing wrong?
                      > TIA
                      >
                      > (function () {
                      > var loader = new YAHOO.util.YUILoade r();
                      > loader.loadOptional = true;
                      >
                      > loader.require( "reset-fonts- grids","base" ,"datatable" ,"dragdrop" ,"selector" );
                      > loader.insert( {
                      > onSuccess: function() {
                      > //shortcuts
                      > var $C = YAHOO.util.Connect,
                      > $E = YAHOO.util.Event,
                      > $D = YAHOO.util.Dom,
                      > $L = YAHOO.lang,
                      > $ = $D.get,
                      > $DT = YAHOO.widget. DataTable;
                      > $DT.prototype. refreshRow = function(row) {
                      > var $D = YAHOO.util.Dom;
                      >
                      > $D.batch($D. getChildren( this.getTrEl( row)),this. formatCell, this,true) ;};
                      >
                      > $DT.formatCell = function(elCell, oRecord, oColumn){
                      > alert("FORMAT CELL:" + oRecord.getData( "firstNum" ));
                      > elCell.innerHTML = (oRecord.getData( "firstNum" ) +5);
                      > alert(elCell. innerHTML)
                      > }
                      >
                      >
                      > // This is just for the sample SSN example described below.
                      > var dtSSN = new $DT(
                      > 'theContainer' ,
                      > [{
                      > key:'firstNum' ,
                      > formatter:$DT. formatNumber,
                      > editor:"textbox"
                      > },
                      > {key:'secondNum' ,formatter: $DT.formatCell}
                      >
                      > ],new YAHOO.util.DataSour ce(
                      > [{firstNum:12} ],
                      > {
                      > responseType: YAHOO.util. DataSource. TYPE_JSARRAY,
                      > responseSchema: {fields:['firstNum' ]}
                      > })
                      > );
                      >
                      > dtSSN.subscribe( 'cellClickEvent' ,
                      > dtSSN.onEventShowCe llEditor) ;
                      > dtSSN.subscribe( 'editorSaveEvent ',$DT.formatCell )
                      >
                      > }
                      > });
                      > })();
                      >
                      > From: Satyam <satyam@satyam. com.ar>
                      > To: ydn-javascript@ yahoogroups. com
                      > Sent: Friday, October 3, 2008 8:19:31 AM
                      > Subject: Re: [ydn-javascript] Database InLine editing Affecting Values
                      > of other columns in Row
                      >
                      > You don't. The formatter function does the calculation just as the
                      > first time. When you call formatCell, it will eventually call your
                      > formatter function which picks the values of the other fields in the
                      > record and does the calculation once again.
                      >
                      > Satyam
                      >
                      > Donna Lanasa wrote:
                      > > ok this is a really stupid question, but when I call formatCell, how
                      > > do I specifically
                      > > assign the new value to the calculated Column?
                      > >
                      > > ----- Original Message ----
                      > > From: Satyam <satyam@satyam. com.ar <mailto:satyam% 40satyam. com.ar>>
                      > > To: ydn-javascript@ yahoogroups. com
                      > <mailto:ydn- javascript% 40yahoogroups. com>
                      > > Sent: Thursday, October 2, 2008 2:37:49 PM
                      > > Subject: Re: [ydn-javascript] Database InLine editing Affecting Values
                      > > of other columns in Row
                      > >
                      > > The value would never be stored, it would only be displayed. By
                      > > assigning a formatter, you would get the cell in the table filled with a
                      > > calculated value, but it would not get stored elsewhere, it doesn't need
                      > > to, anyway. In editorSaveEvent just call formatCell on the cell with
                      > > the calculated value, that would force a recalculation of that cell
                      > > based on the values of the other fields in the record, just as the first
                      > > time around.
                      > >
                      > > Satyam
                      > >
                      > > Donna Lanasa wrote:
                      > > > ok, so I have the field computing on the first render of the table,
                      > > > but after I text edit another column in that row and call
                      > > editorSaveEvent,
                      > > > I can access the values for all the columns except the one that was
                      > > > computed.
                      > > > I get 'undefined'. It seems like tha value is not being saved...
                      > > > What am I doing wrong?
                      > > >
                      > > > Thx
                      > > > D
                      > > > ----- Original Message ----
                      > > > From: Satyam <satyam@satyam. com.ar <http://com.ar>
                      > <mailto:satyam% 40satyam. com.ar>>
                      > > > To: ydn-javascript@ yahoogroups. com
                      > > <mailto:ydn- javascript% 40yahoogroups. com>
                      > > > Sent: Wednesday, October 1, 2008 11:21:14 PM
                      > > > Subject: Re: [ydn-javascript] Database InLine editing Affecting Values
                      > > > of other columns in Row
                      > > >
                      > > > You can list columns in the column defs array that don't exist in the
                      > > > responseSchema. fields array. Those columns need to have a formatter
                      > > > function defined because otherwise they would be empty.
                      > > >
                      > > > http://developer. yahoo.com/ <http://yahoo. com/> <http://yahoo.
                      > com/ <http://yahoo. com/>> yui/datatable/ #format
                      > > > <http://developer. yahoo.com/ yui/datatable/ #format
                      > > <http://developer. yahoo.com/ yui/datatable/ #format
                      > <http://developer. yahoo.com/ yui/datatable/ #format>>>
                      > > >
                      > > > The formatter function has access to all values in the record and can
                      > > > calculate the value for this extra column based on them.
                      > > >
                      > > > At anytime you want to refresh the value on that column, you can call
                      > > > formatCell:
                      > > >
                      > > > http://developer. yahoo.com/ yui/docs/ YAHOO.widget. DataTable.
                      > > > html#method_ formatCell
                      > > > <http://developer. yahoo.com/ yui/docs/ YAHOO.widget. DataTable.
                      > > html#method_ formatCell
                      > > <http://developer. yahoo.com/ yui/docs/ YAHOO.widget. DataTable.
                      > html#method_ formatCell
                      > <http://developer. yahoo.com/ yui/docs/ YAHOO.widget. DataTable. html#method_ formatCell>>>
                      > > >
                      > > > for example, in response to editorSaveEvent:
                      > > >
                      > > > http://developer. yahoo.com/ yui/docs/ YAHOO.widget. DataTable.
                      > > > html#event_ editorSaveEvent
                      > > > <http://developer. yahoo.com/ yui/docs/ YAHOO.widget. DataTable.
                      > > html#event_ editorSaveEvent
                      > > <http://developer. yahoo.com/ yui/docs/ YAHOO.widget. DataTable.
                      > html#event_ editorSaveEvent
                      > <http://developer. yahoo.com/ yui/docs/ YAHOO.widget. DataTable. html#event_ editorSaveEvent>>>
                      > > >
                      > > > Satyam
                      > > >
                      > > > daisyhmazie wrote:
                      > > > > Hi!
                      > > > > Im new using YUI and very rusty with my javascript. Im having
                      > trouble
                      > > > > figure out how to firstly have a column that's calculated from the
                      > > > > values of another column in the record. And secondly, when a column
                      > > > > is edited, have the calculated column change it's value based on the
                      > > > > new value entered.
                      > > > > TIA!
                      > > > > D
                      > > > >
                      > > > >
                      > > > > ------------ --------- --------- ------
                      > > > >
                      > > > > Yahoo! Groups Links
                      > > > >
                      > > > >
                      > > > >
                      > > > > ------------ --------- --------- --------- --------- --------- -
                      > > > >
                      > > > >
                      > > > > No virus found in this incoming message.
                      > > > > Checked by AVG - http://www.avg. com <http://www.avg. com
                      > > <http://www.avg. com <http://www.avg. com>>>
                      > > > > Version: 8.0.169 / Virus Database: 270.7.5/1702 - Release Date:
                      > > > 01/10/2008 9:05
                      > > > >
                      > > > >
                      > > >
                      > > >
                      > > >
                      > > > ------------ --------- --------- --------- --------- --------- -
                      > > >
                      > > >
                      > > > No virus found in this incoming message.
                      > > > Checked by AVG - http://www.avg. com <http://www.avg. com
                      > <http://www.avg. com>>
                      > > > Version: 8.0.173 / Virus Database: 270.7.5/1703 - Release Date:
                      > > 02/10/2008 7:46
                      > > >
                      > > >
                      > >
                      > >
                      > >
                      > > ------------ --------- --------- --------- --------- --------- -
                      > >
                      > >
                      > > No virus found in this incoming message.
                      > > Checked by AVG - http://www.avg. com <http://www.avg. com>
                      > > Version: 8.0.173 / Virus Database: 270.7.5/1703 - Release Date:
                      > 02/10/2008 7:46
                      > >
                      > >
                      >
                      >
                      >
                      > ------------ --------- --------- --------- --------- --------- -
                      >
                      >
                      > No virus found in this incoming message.
                      > Checked by AVG - http://www.avg. com
                      > Version: 8.0.173 / Virus Database: 270.7.5/1703 - Release Date: 02/10/2008 7:46
                      >
                      >

                    Your message has been successfully submitted and would be delivered to recipients shortly.