[Feature proposal] Adding a parameter to fnDrawCallback

[Feature proposal] Adding a parameter to fnDrawCallback

manuelmanuel Posts: 5Questions: 0Answers: 0
edited April 2011 in General
Hi,

I am in a situation where I need to perform either full or partial re-draws of a table, and have a couple of "chained" tables, i.e. when selecting a row in one table it re-draws a second table (re-drawing is what I have found to be the best way of refreshing data when using the server-side data provisioning mechanism).

In order to "chain" the tables, I added a fnDrawCallBack in the first table that triggers a full refresh of the second table (because the data in the second table may entirely changed based on what's selected in the first one). This is allright as long as I don't want a partial re-draw of the second table.

When I want to only trigger a partial re-draw of the second table however (because some information got updated but the selection in both tables stays the same), I lack the information "this is a partial re-draw" in fnDrawCallBack.

Thus, my proposal would be to add a boolean parameter to fnDrawCallBack which indicates whether one has called fnDraw(true) or fnDraw(false).

What do you think, does it make sense / would it be possible to implement it?

Thanks!

Manuel

Replies

  • allanallan Posts: 63,520Questions: 1Answers: 10,473 Site admin
    I don't think this is possible in DataTables itsellf since the draw function knows nothing about whether it is a full or partial redraw - the boolean value you refer to will cause fnDraw to either call the sorting and filtering functions followed by the draw function, or just the draw function itself.

    However, can't you just set a flag? You know if you are passing in true or false to the function - just set a flag when you do so and then act on that in fnDrawCallback.

    Allan
  • manuelmanuel Posts: 5Questions: 0Answers: 0
    Hi Allan,

    I looked at the code, as far as my understanding goes, what my proposal would mean is to add a parameter to the _fnDraw( oSettings ) function that indicates whether it has been called due to a re-draw or due to a full draw. Then, this value could also be passed to the callback...I think.

    That being said, I am not sure how big would be the impact of such a change, I just quickly glanced at the source (very well documented, by the way).

    I'll look into setting a flag for the moment, thanks for the hint!

    Manuel
  • allanallan Posts: 63,520Questions: 1Answers: 10,473 Site admin
    Sorry, I misspoke. Yes indeed it is of course possible to do, however, I don't think it is the right thing to do, nor would it be particularly flexibly. _fnDraw is called from a number of places, not just this.fnDraw - so that would need to be taken into account. Since it can be done externally, I think that is probably the best approach.

    Allan
This discussion has been closed.