Problem with Javascript with TDC control

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • sheldonlg

    Problem with Javascript with TDC control

    I have inherited code with a TDC control. In this file, there are two
    javascripts of interest. One of these is a function, filter(), which is
    inside
    <script language=javasc ript></script>.

    The other is code inside
    <script language=javasc ript FOR=inquiry
    event=ondataset complete()></script>
    where inquiry is the TDC.

    The table displays correctly. The problem is in getting the total after
    doing a display and then refreshing the TDC (which invokes the script
    filter() ). That calculation is done in the second script. What
    happens in there is:
    var rs = inquiry.records et;
    extcosttot = 0;
    num = rs.Fields.Count ;
    while(rs.EOF != true)
    {
    extcosttot += parseFloat(rs(9 ).value);
    rs.moveNext;
    }

    When I alert inside the while loop, the very first record from before
    the sorting -- even though the table display properly with the new one.

    I tried to put similar looping code at the end of filter() to examine
    what I get from the TDC refresh, but I got a messages of "Operation is
    not allowed when the object is closed". When I added an open() for I
    got "The connection cannot be used to perform this operation. It is
    either closed or invalid in this context".

    I am at a bit of a loss. I have no idea what happens between the end of
    filter() and the inline script and I have no idea on how to
    successfully put in code to see what is at the end of filter().

    Since there is no code in the generator file for how the sorting is
    taking place, the problem must be after retrieving the recordset,
    observing somehow that it was left at a certain column being sorted, and
    then sorting it accordingly.
  • sheldonlg

    #2
    Re: Problem with Javascript with TDC control

    sheldonlg wrote:
    I have inherited code with a TDC control. In this file, there are two
    javascripts of interest. One of these is a function, filter(), which is
    inside
    <script language=javasc ript></script>.
    >
    The other is code inside
    <script language=javasc ript FOR=inquiry
    event=ondataset complete()></script>
    where inquiry is the TDC.
    >
    The table displays correctly. The problem is in getting the total after
    doing a display and then refreshing the TDC (which invokes the script
    filter() ). That calculation is done in the second script. What
    happens in there is:
    var rs = inquiry.records et;
    extcosttot = 0;
    num = rs.Fields.Count ;
    while(rs.EOF != true)
    {
    extcosttot += parseFloat(rs(9 ).value);
    rs.moveNext;
    }
    >
    When I alert inside the while loop, the very first record from before
    the sorting -- even though the table display properly with the new one.
    >
    I tried to put similar looping code at the end of filter() to examine
    what I get from the TDC refresh, but I got a messages of "Operation is
    not allowed when the object is closed". When I added an open() for I
    got "The connection cannot be used to perform this operation. It is
    either closed or invalid in this context".
    >
    I am at a bit of a loss. I have no idea what happens between the end of
    filter() and the inline script and I have no idea on how to
    successfully put in code to see what is at the end of filter().
    >
    Since there is no code in the generator file for how the sorting is
    taking place, the problem must be after retrieving the recordset,
    observing somehow that it was left at a certain column being sorted, and
    then sorting it accordingly.
    I worked my way around to avoid the problem (not by fixing it), but I
    would still like to know what caused this problem in the first place.

    The call of a filter is done in a javascript routine with setting the
    DataURL and doing inquiry.Reset() where inquiry is the name of the
    dataset object. When it is complete, it calls another javascript (via
    using ondatasetcomple te). The getting of this refreshed dataset has no
    knowledge of any sorting that may have taken place on the columns prior
    to doing the refresh, and the ondatasetcomple te is done automatically
    upon getting the refreshed data.

    What I would like to know is this:
    *************
    Why does the looping through the dataset give all the proper records
    (sorted) except for the first record which is from the unsorted set?
    *************

    For anyone who may be interested, the way I avoided the problem was to
    add an extra field to the dataset. In the display page, I set the style
    of that column to "display:no ne". In that field, I place the cumulative
    total for all the records, and all records hold the same total. In the
    DataURL, I delayed writing of the records by putting them into an array,
    and at the end of the fetching, modifying all the lines in the array by
    setting the same cumulative total into that last field. Then I print out
    the entire array in the appropriate format.

    Comment

    Working...