Terra Informatica Forums » htmlayout

the efficiency of updating a element.

(10 posts)
  • Started 3 years ago by atlantis11500
  • Latest reply from atlantis11500

Tags:


  1. atlantis11500
    Member

    I have a html like this:

    <div ...>
    <table...>
    <tr></tr>
    <tr></tr>
    ......
    <tr></tr>
    </table>
    </div>

    <div ...> //Progress info window
    <div id=ProgressTitle...> ....</div>
    <div id=ProgressImage...>....</div>
    <div id=progressInfo...>...</div>
    </div>

    I have a huge table that has more than 1000 rows which contains data information. While user clicks on a button, i will process data within this rows and promopt the progress information window to show the current progress, you can imagine it just looks like the system copying file dialog.

    The progress information window shows right on the center of the table. The pe-sucode as follows:

    OnAction
    {
    CenterProgressWindow();

    int nRow = 0;
    for_each_row_in_table
    {
    upgrade_progresstitle(nRow...)
    upgrade_progressvalue(tabledata[nrow][0]...)
    upgrade_progressinfo(tabledata[nrow][2])....
    ....
    }
    .....
    }

    I found it's strange that the application gets slowlier and slowlier while while table row count gets bigger. E.g. the more table row i have, the more slowlier the application runs.

    I use the Update function to upgrade the element status, such as text or css style, I guess because the progress information window is right on the center of the table, so when i update the elments in the progress window, the table need to update as well?

    Another interesting thing:
    <div id="parent">
    <ELEMENT id="e1">...
    <ELEMENT id="e2">...
    <ELEMENT id="e3">...
    </div>

    code1.
    e1.set_text(...)
    e1.update();

    e2.set_text(...)
    e2.update();

    e3.set_text(...)
    e3.update();

    code2.
    e1.set_text(...)
    e2.set_text(...)
    e3.set_text(...)

    parent.update();

    It seams that code2 runs fast than code1. Why?

    Is there any information regarding the update function, when should I pass TRUE as the parameter and when to pass FALSE? Any tricks to improve the efficiency?

    Thanks in advance!

    Posted 3 years ago #
  2. As far as I understand your progress window is the thing that needs to be updated frequently. If yes then use overflow:hidden for its content.

    Any value of overflow other than none effectively isolates updates inside.

    Posted 3 years ago #
  3. e1.set_text just updates value of the DOM element.
    and parent.update() measures the container. Measurement of HTML is pretty expensive operation so

    e1.set_text(...)
    e2.set_text(...)
    e3.set_text(...)
    
    parent.update();

    works better as measurement (update) happens only once.

    Use of
    e1.set_text(...); e1.update();

    does not help too much because e1.set_text(...) may change dimension of the element e1. And so may trigger change of dimension of its container and so on.

    As I said above to stop this cascading updates use overflow:hidden. Overflowed elements have "static" dimensions. Dynamic change of their content will not cause change of their dimensions.

    Posted 3 years ago #
  4. atlantis11500
    Member

    The fllow feature seams to doesn't work for me.

    I have upload the source code of my demo to the following URL:
    http://files-upload.com/164201/source.rar.html

    There are three buttons on the dialog,
    1. Fill 100 rows
    2. Fill 2000 rows
    3. Test

    You can use either "Fill 100 rows" to generate a table with 100 rows or use "Fill 2000 rows". And then, click on the test button, you will see the differences between 100 rows and 2000 rows.

    Posted 3 years ago #
  5. I cannot see anything to download on the page:
    http://files-upload.com/164201/source.rar.html

    Posted 3 years ago #
  6. atlantis11500
    Member

    You need to wait for 30 seconds. There is a down counter at the center bottom of this page.

    I emailed you this demo just now.

    Posted 3 years ago #
  7. Thanks. Got it.

    I'll fix my update algorithm to handle cases like yours. Will publish build tomorrow.

    Posted 3 years ago #
  8. atlantis11500
    Member

    Thank you so so much!!!

    Posted 3 years ago #
  9. atlantis11500
    Member

    Hi, andrew, where can I download the latest build?
    It seams that the latest version is release on 03-31,2007.

    Posted 3 years ago #
  10. atlantis11500
    Member

    Got it! Thanks!

    Posted 3 years ago #

RSS feed for this topic

Reply

You must log in to post.