I am very experienced and I want to write an extension
I am very experienced and I want to write an extension
chrispinto
Posts: 3Questions: 1Answers: 0
I want to write an extension that added a table filter that is for exclude from query results.
Is there a decent example of implementing an extension that I could use to learn how to wire everything together???
This discussion has been closed.
Answers
In the plugins section is more information on how you can contribute.
And you can find source examples on github which you can examine.
I'll take a look, but I am thinking that I'll need to have access to the internal function _fnFilterComplete like the implementation of the API registered function 'search()' does.
Thoughts?
Maybe I need to contribute to the project to achieve this?
Chris
P.S. Thanks for the timely response.
Hi Chris,
You shouldn't need to access
_fnFilterComplete
for a search plug-in - indeed I think that would actually cause all sorts of looping issues.Instead define your own search plug-in which will read a value from whatever control you want to let your end user enter the "exclude" information and perform your search logic in that function. DataTables will automatically call your function whenever it needs to.
One other option is to use regex - if the exclude is just a simple string, you could use the regex options to just prefix a
^
. That won't work with the "smart filtering" though.Allan
Allan,
But this won't call a backend server side function, will it?
I have my own function in options.fnServerData and I want to have two separate filter boxes
Filter for stuff we find
Filter our stuff that we find
Search for these strings [ some string ]
Exclude these strings [some text that will cause those rows to not be in the search results]
This is because my back end talks to elasticsearch and we want to provide terms to search for in the data and terms to filter out in separate inputs.
Does that makes sense?
When I get into my backend function I get global search term like so:
globalSearch = oSettings.oAjaxData.search.value
I want to get and exclude like so
globalExclude = oSettings.oAjaxData.exclude.value
Chris
Hi Chris,
Are you using server-side processing? If so, then yes, that changes things significantly since it is the server-side script that does all of the filtering.
If you are using server-side processing and just want to submit some extra information, you can do so using the technique demonstrated here.
I would recommend not using the settings object at all if you possibly can.
Allan