Use .aoDrawCallback.push() or delegate/on("draw", and various Data sources

Use .aoDrawCallback.push() or delegate/on("draw", and various Data sources

daniel_rdaniel_r Posts: 460Questions: 4Answers: 67
edited March 2013 in General
Hi,

I'm in final stage of writing a column filter plugin for datatables and I was wondering how should I register it to be executed upon each table redraw, should I use .aoDrawCallback.push or bind to draw event with jquery ?

Another thing that I noticed that non of the approaches I just mentioned not firing when data source of the table is DOM, but it does works just fine when using the Ajax source as data source (I guess that it will work just fine for Server side processing, but not sure what gonna happen with Javascript array as data source), why ?

My last question would be what is the best practice to recognize what is the data source of the table ? DOM/Javascript array/Ajax source/Server side processing

If I better split the question into several smaller ones please let me know,

Thanks ahead,

Daniel.

Replies

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    Either should work just fine. The draw event might be best, but it doesn't make much difference.

    I don't really understand about it not firing when the table is DOM sourced. Can you link to a test case showing that issue please?

    > My last question would be what is the best practice to recognize what is the data source of the table ? DOM/Javascript array/Ajax source/Server side processing

    For server-side processing, if `settings.oFeatures.bServerSide` is true, then it is SSP. Otherwise if `settings.sAjaxSource` is set then it is Ajax sourced, otherwise DOM of JS sourced.

    Allan
  • daniel_rdaniel_r Posts: 460Questions: 4Answers: 67
    Thanks ,

    Here a jsbin example http://jsbin.com/ukimeq/3/

    If you look at the plugin file jquery.dataTables.yadcf.js which is hosted on static.tumblr.com (can be accessed from dev tools of browser or here https://github.com/vedmack/yadcf/blob/master/jquery.dataTables.yadcf.js)


    So when working with DOM as source i had to add
    [code]
    if (oTable.fnSettings().sAjaxSource === null) {
    appendSelectFilter(yadcf.getOptions());
    }
    [/code]

    And while when working with sAjaxSource its enough to run it on draw event

    b.t.w if you had any feedback on my filter plugin let me know :)
This discussion has been closed.