Adding span to TD really slow things down in DOM creating table

Adding span to TD really slow things down in DOM creating table

RokyRoky Posts: 6Questions: 0Answers: 0
edited November 2013 in General
Do: Use the DataTables debugger:
http://debug.datatables.net/oxuhid

Description:
I generate additional HTML markup in every td. Example bellow:
tempHtml += ''+jQuery(this).attr('name')+' '+jQuery(this).attr('description')+''

Problem:
When I add to the HTML it really slow things down, like 18 seconds for 20 rows.


Test case:
You can try to add:
tempHtml = 'test

or

tempHtml = 'test

and then use your fnAddTr plug-in. You will see the speed difference.

Replies

  • allanallan Posts: 63,383Questions: 1Answers: 10,449 Site admin
    Is this only occurring with fnAddTr? It would be great if you could link us to a page showing the problem please.

    Allan
  • RokyRoky Posts: 6Questions: 0Answers: 0
    This only occurs when using fnAddTr. If I manually add DOM trough jquery and then call / initialize datatables after DOM has been appended to Table > tbody everything is working fine.

    I cannot link you the the page, as this is an internal web application which needs C# service in order to work.

    Please let me know if I can help you debug in any other way.

    Cheers,
    Rok Meglič
  • RokyRoky Posts: 6Questions: 0Answers: 0
    Hello Allan,

    did you have time to look into this? Thank you!

    Cheers,
    Rok
  • RokyRoky Posts: 6Questions: 0Answers: 0
    Hello Alan,

    is this error not under "free support" and we need to purchase your time? No problem, just let me know.

    Cheers,
    Rok Meglič
  • allanallan Posts: 63,383Questions: 1Answers: 10,449 Site admin
    Sorry for the delay in reply. Everything qualifies for "free support", but I've only got a limited amount of time to spend on such cases, hence why I can't answer all questions unfortunately. Test cases as massively helpful so I can quality identify the issue and say what is wrong.

    For example, how are you using fnAddTr? Is it in a loop? If so, are you telling it to not redraw on every addition?

    Allan
  • RokyRoky Posts: 6Questions: 0Answers: 0
    No problem Allan, I totally understand.

    Yes, it is in the loop and the parameter for redraw is false.
    You can check the "API: plug-in methods" from debug URL: http://debug.datatables.net/oxuhid .

    As I said. The problem only occurs if you add to the HTML.
  • allanallan Posts: 63,383Questions: 1Answers: 10,449 Site admin
    Very odd! I'll try to set aside some time next week to create a test case myself of this, but it would be massively helpful and let me look at this much quicker if you were able to provide one.

    Another option is to consider using DataTables 1.10 which has the ability to add TR elements built into its new API - `row.add( ... )` will accepts a node, object or array.

    Allan
  • RokyRoky Posts: 6Questions: 0Answers: 0
    If you tell me when you will have time, we can arrange teamviewer ... and you can check on my C# installation.

    As I said you can easily test this with:

    tempHtml = 'test
    and then user your plugin fnAddTr .
  • allanallan Posts: 63,383Questions: 1Answers: 10,449 Site admin
    I've just put this example together and it seem pretty damn fast to me: http://live.datatables.net/igocuk/edit#javascript,html . 1000 rows added.

    With span: http://live.datatables.net/igocuk/2/edit - no real difference that I can see.
This discussion has been closed.