how to accomodate two datatable in one page

how to accomodate two datatable in one page

espresso74espresso74 Posts: 11Questions: 0Answers: 0
edited February 2010 in General
hi,

I just put two datatables into my webpage, and ended up with error saying aoData is null. I wonder if it is possible to put two different datatables into one page. these two datatables have little bit different (columns, etc).

and i currently using datatable.pipeline, server side processing.

please advice.

thanks
dave

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Hi Dave,

    Yes it's certainly possible ( http://datatables.net/examples/basic_init/multiple_tables.html ) - however I suspect the complication you are seeing here is due to the pipelining. You need to have separate instances of the pipeline processor, in order to have individual cache etc for each table. Easest way would be to duplicate and rename the function. However, there are better ways, which would allow truly unique instances to be created - it just wasn't written with that in mind originally.

    Regards,
    Allan
  • espresso74espresso74 Posts: 11Questions: 0Answers: 0
    it is so appreciated for your prompt reply.

    I will do a demo as for what u have suggest soon. and will let you know the results.

    Thanks
    Dave
  • espresso74espresso74 Posts: 11Questions: 0Answers: 0
    that is cool. It already working as per what you have told.

    yes, i duplicated the function, made the function name & Cache name different and it was working.

    anyway, hopefully this pipeline functionality could be encapulated as Instance(as you said) in the future release.

    again, thanks for your great products.

    Cheers
    Dave
  • gkoehlgkoehl Posts: 1Questions: 0Answers: 0
    This is my first post, but I encountered the same situation you were today expresso. Instead of creating multiple functions I have done the following:

    [code]
    var oCache = {
    "table_id1":{"iCacheLower":-1},
    "table_id2":{"iCacheLower":-1},
    ...
    };
    [/code]

    Then I made the following change within the function:

    [code]
    function fnDataTablesPipeline(sSource,aoData,fnCallback) {
    var sTableId = this.sTableId;
    //anywhere oCache is called, I instead swapped in oCache[sTableId]
    ...
    [/code]

    Let me know what you think or if you see any issues with the idea. Obviously you'd have to individually ID tables but other than that, I believe this should work.

    All the best,
    Gary
This discussion has been closed.