Overwrite private function

Overwrite private function

IdeabileIdeabile Posts: 3Questions: 0Answers: 0
edited March 2013 in General
Hi to everybody,
I start to use this week datatables. I found really useful tool for paginating different type of data. Fantastic!

But for make more consistency I try to make a "plugin" for integrate in bootstrap ( Something liked I found around in the blog of Datatables ).

The first customization I try to do; fail when I try to overwrite the function _fnFeatureHtmlFilter.
I want customize this function for get a different html output for the filters.

[code]
/* Change search html */
$.fn.dataTableExt.oApi._fnFeatureHtmlFilter = function ( oSettings )
{
[...]
};
[/code]

What I do wrong? Is possible overwrite _fn functions? I look at the code and I find a handler, so need to work theoretically.

Thanks previously for all reply.
Mauro.

Replies

  • allanallan Posts: 63,516Questions: 1Answers: 10,473 Site admin
    > Is possible overwrite _fn functions?

    No. You've overwritten the reference to the private function there, not the function itself - it is private.

    If you want to modify it, you need to modify DataTables.

    Allan
  • IdeabileIdeabile Posts: 3Questions: 0Answers: 0
    edited March 2013
    Hi Allan! Thanks, but what you think abouth the maintainability? In this way I need every time to update all library in case of update of the libraries. Do you think I can do in a way were I can make this customization for distrubuited it?

    My finally idea is develop a bootstrap version of datatables. Do you appreciate it?

    Mauro.

    Edit:
    What is the patner you uses for the plugin? jQuery basic factory? how you expone to Api?

    Sorry for this question,
    I know take your time but I want do this customization with your design pattern.
  • allanallan Posts: 63,516Questions: 1Answers: 10,473 Site admin
    Hi,

    In terms of paintability, it would obviously be good to not overwrite the internal functions since you'd need to merge every release of DataTables. You are of course free to do that, that's entirely up to yourself.

    However, I would say that I already support Bootstrap through an integration plug-in, which is available here: https://github.com/DataTables/Plugins/tree/master/integration/bootstrap

    This I consider to be a core part of DataTables and will be come increasingly so, particularly in v1.11 (hopefully towards the end of this year).

    Is there anything you think I've missed from this Bootstrap integration?

    Regards,
    Allan
  • IdeabileIdeabile Posts: 3Questions: 0Answers: 0
    edited March 2013
    Hi Allan,
    I found some cool customization in your Bootstrap datatable integration.
    For example you customize the oPagination passing a case of 'bootstrap' in the configuration and after you are able to overwrite the functions liked 'fnInit'.

    In the same way I want do for example to cOption is 'f':
    when you append the search, you put the input inside the tag. And really I don't like it (but in any case is valid html). Also I want be able to add some custom classes to the search input and why not also some custom buttons just to press search for example.

    But maybe this is the wrong way, maybe is better I just make a TableTools like plugin with the ancor to other cOption tags.

    Cheers,
    Mauro.
  • allanallan Posts: 63,516Questions: 1Answers: 10,473 Site admin
    Why don't you like the input being inside a label? The HTML spec defines this as explicit referencing and is absolutely fine to do. Using `for` would need an ID added to the input (which could be done, but is not required).

    > Also I want be able to add some custom classes to the search input and why not also some custom buttons just to press search for example.

    Use `div.dataTable_filter input` as your selector?

    Allan
This discussion has been closed.