SearchBuilder Does Not Work On Server Side Instances
SearchBuilder Does Not Work On Server Side Instances
wilecoyte78
Posts: 2Questions: 1Answers: 0
https://codepen.io/wilecoyte78/pen/rNegEoZ
I am trying to do SearchBuilder on a server side instance and it is not working.
When I use hard coded table with values it works fine.
There are no errors in the console when I try to set the SearchBuilder query.
Also in the network tab for the headers of the requested file I do not see any thing from the SearchBuilder being passed.
Answers
The SearchBuilder blog has this information:
Kevin
Ok I did not see that till now.
Is it still not available? the server side filtering?
No - SearchBuilder does not yet support server-side processing.
If you are interested in contributing support for it though, I'd be happy to help point out the areas of the code that will need to be modified to add such support.
Regards,
Allan
Hi Allan,
Would be interested in helping with that tremendously useful feature. I will dive in SearchBuilder's code but if you had any pointer for where to begin, it'd be super nice.
Thanks for the great work!
Sure thing - what you would need to do is add a
preXhr
listener to the DataTable in the SearchBuilder constructor that would send information to the server able the currently selected search terms.The big chunk of work for this is going to be the implementation of the conditions on the server-side (our Editor PHP, .NET and NodeJS libraries will be our targets for this - they are open source, so can be used without Editor if required). There is a
process
method in each of those libraries which calls aget
method. It is there that the filtering would need to be applied to the query that is generated for the database.Allan
Wow, I wasn't expecting the backend side :-P. I never used your built-in backends, since I use DataTables exclusively with Python/Django custom backends. I can still give it a shot, but I sure am no PHP/.NET/Node developer :-/.
On the frontend side, is the
preXhr
listener enough? I suspect it's not, since the actual filtering (which I still cannot quite figure out where it is done) on the loaded table should not be performed, right?When you are using server-side processing, the filter is all done at the server. So yes, using
preXhr
is how plug-ins such as SearchBuilder can hook into the draw action and attach extra data to send to the server.Are you sure you are using server-side processing? Do you have the
serverSide
option set?Allan
I definitely am using Datatables with
serverSide
;-)What I meant is:
preXhr
so that search parameters built withSearchBuilder
are sent to the server.preXhr
enough? I suppose that implementingpreXhr
will not disableSearchBuilder
's default behavior of trying to filter/redraw the table client-side, right?You are correct - it wouldn't disable the default behaviour, so there would need to be a condition added into the search filters added client-side (or better yet, just disable them outright). I'll ask my colleague @sandy to comment on where this might be best done (although he is currently off until Friday).
Hi @seb-ksl ,
Each SearchBuilder condition is represented by an object with a couple of methods and properties to design it's functionality. See the documentation here. I think the solution here that would mean the least impact on the rest of the code would be to create a couple of new sets of conditions specifically for SSP. One for each data type would probably be best, so something along the lines of
serverSide-string
serverSide-date
serverSide-num
serverSide-moment
serverSide-array
serverSide-num-fmt
serverSide-html
serverSide-html-num
serverSide-html-num-fmt
You could then change the behaviour of the functions that go on each to provide the behaviour that is indicated in the documentation. You would need to modify the code here as well to make sure that the serverSide options were being selected when SSP was active.
You can see the current code to setup the conditions here.
Hopefully this in turn with a listener on the
preXhr
should be enough, but I would expect some bugs along the way - as is always the case!Hope this helps,
Sandy
Hi @sandy
I'm also looking into implementing SSP with searchbuilder and what i've discovered is the issue of the data collection phase not being able to incorporate the server because the code doesn't invoke any events in _populateData where the dropdown for values is determined (Unless im missing something).
That means that for a serverside table only values can be selected from the dropdowns that are in the current page. Can you add an event or callback function so that SSP can hook onto that?
That is correct and also one of the issues that server-side processing is going to face with SearchBuilder.
Sandy is going to be looking into making SearchBuilder work with server-side processing over the summer.
Allan
Hello @sandy,
Have you already been working on making server-side processing support for SearchBuilder. How it is going?
Best regards,
Kamil
It's going good! We're in the testing phase now (I'm kicking it around the field as I type), so suspect it'll be a few more days, probably end of next week, before it gets released,
Colin
Hi Colin,
I'm really keen on seeing how the testing phase is going on with the SearchBuilder supporting server-side processing, as I'd like to integrate this to my project.
Are you planning a blog post on the integration?
Cheers,
OrdinaryEngineer
It went well, all complete. It doesn't need any integration, it just works out of the box, but yep, there will be a blog post introducing it. The releases were delayed on Friday, so we're aiming to push them out at the start of the week, in a day or two.
Colin
Great thanks,
Will this be in a blog post or covered in the extension's page? As I am looking to prepare for this setup, will there be any changes required to ssp.class.php?
Cheers,
OrdinaryEngineer
Hi,
Documentation for it is now here. We won't be updating the SSP class to support SearchBuilder, but our PHP libraries for Editor (which you can use without an Editor license) do support it.
Allan
Also there is an example of it working here.
Allan
For now, it's in the examples pages. We released it a few minutes ago so a well timed ping. There are examples here. I don't believe that script changed, but it's probably worth getting the most recent just in case.
Colin
I would be interested in this as well. What versions / special setup is required to get this to work?
Thanks
SearchBuilder 1.2+ and Editor 2.0.5+ server-side libraries (or your own with support for the parameters documented).
Allan
What a coincidence, I was looking for this feature and you released it minutes ago.
I am probably a corner case, but I have a custom ajax object with a data function to rejigger some things for our platform. However it looks like the
call happens after the check for ajax.data, so my function doesn't see the searchCriteria stuff automagically added to the data parameter that gets passed into my function.
Posting this in case someone is scratching their head.
Hi @colin
Thank you for this wonderful news.
I have spent hours testing the SearchBuilder on server-side DataTables (I am using SSD Class).
However, I fail to get it working. I have added the editor library, the examples from the zip file are working, but I don't understand where to use the below code alongside the server-side processing PHP code where the SSD class in also included.
`// DataTables PHP library
include( "../lib/DataTables.php" );
// Alias Editor classes so they are easy to use
use
DataTables\Editor,
DataTables\Editor\Field,
DataTables\Editor\Format,
DataTables\Editor\Mjoin,
DataTables\Editor\Options,
DataTables\Editor\Upload,
DataTables\Editor\Validate,
DataTables\Editor\ValidateOptions;`
That would go into the
controllers
directory alongside the other scripts. For example, the Editor example, usesstaff.php
, which is placed here:Colin
It would be worth sticking to a single thread for a question, otherwise Colin and I will overlap and both get confused .
Allan
By any chance are there any examples for searchBuilder with server side processing for aspx
This example using the Editor libraries - how to do that is discussed in this blog post. While the examples are using PHP, Editor also has .NET and .NETFramework libraries too, and the example will work as described with those.
Colin
Hello,
We are using Datatables with Server-side processing and sending the search/request details in JSON format as suggested in the below link.
https://datatables.net/forums/discussion/26282/posting-json-with-built-in-ajax-functionality
When we try to use Search Builder, search/request details are sent in form data format. Please help us in fixing it.
Thank you.
Gangadhar