SearchBuilder Does Not Work On Server Side Instances

SearchBuilder Does Not Work On Server Side Instances

wilecoyte78wilecoyte78 Posts: 2Questions: 1Answers: 0
edited September 2020 in Free community support

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

  • kthorngrenkthorngren Posts: 13,816Questions: 25Answers: 3,252

    The SearchBuilder blog has this information:

    As was the case with SearchPanes' initial release, server-side processing is not available in this 1.0.0 release either. We are going to be looking at adding this ability in future,

    Kevin

  • wilecoyte78wilecoyte78 Posts: 2Questions: 1Answers: 0

    Ok I did not see that till now.

  • SarramSarram Posts: 1Questions: 0Answers: 0

    Is it still not available? the server side filtering?

  • allanallan Posts: 54,714Questions: 1Answers: 8,560 Site admin

    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

  • seb-kslseb-ksl Posts: 4Questions: 1Answers: 0

    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!

  • allanallan Posts: 54,714Questions: 1Answers: 8,560 Site admin

    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 a get method. It is there that the filtering would need to be applied to the query that is generated for the database.

    Allan

  • seb-kslseb-ksl Posts: 4Questions: 1Answers: 0

    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?

  • allanallan Posts: 54,714Questions: 1Answers: 8,560 Site admin

    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

  • seb-kslseb-ksl Posts: 4Questions: 1Answers: 0

    I definitely am using Datatables with serverSide ;-)

    What I meant is:

    • Sure I understand the need for the preXhr so that search parameters built with SearchBuilder are sent to the server.
    • But is the preXhr enough? I suppose that implementing preXhr will not disable SearchBuilder's default behavior of trying to filter/redraw the table client-side, right?
  • allanallan Posts: 54,714Questions: 1Answers: 8,560 Site admin

    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).

  • sandysandy Posts: 694Questions: 0Answers: 189

    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

  • DakrorDakror Posts: 1Questions: 0Answers: 0

    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?

  • allanallan Posts: 54,714Questions: 1Answers: 8,560 Site admin

    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

  • radz2kradz2k Posts: 1Questions: 0Answers: 0

    Hello @sandy,

    Have you already been working on making server-side processing support for SearchBuilder. How it is going?

    Best regards,
    Kamil

  • colincolin Posts: 12,657Questions: 0Answers: 2,163

    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

  • ordinaryengineerordinaryengineer Posts: 2Questions: 0Answers: 0

    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

  • colincolin Posts: 12,657Questions: 0Answers: 2,163

    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

  • ordinaryengineerordinaryengineer Posts: 2Questions: 0Answers: 0

    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

  • allanallan Posts: 54,714Questions: 1Answers: 8,560 Site admin

    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

  • allanallan Posts: 54,714Questions: 1Answers: 8,560 Site admin
  • colincolin Posts: 12,657Questions: 0Answers: 2,163
    edited August 25

    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

  • GstgGstg Posts: 44Questions: 0Answers: 0

    I would be interested in this as well. What versions / special setup is required to get this to work?

    Thanks

  • allanallan Posts: 54,714Questions: 1Answers: 8,560 Site admin

    SearchBuilder 1.2+ and Editor 2.0.5+ server-side libraries (or your own with support for the parameters documented).

    Allan

  • nicksvnicksv Posts: 1Questions: 0Answers: 0

    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

            // Allow plug-ins and external processes to modify the data
            _fnCallbackFire( oSettings, null, 'preXhr', [oSettings, data] );
    

    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.

  • poeziafreepoeziafree Posts: 35Questions: 11Answers: 0

    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;`

  • colincolin Posts: 12,657Questions: 0Answers: 2,163

    That would go into the controllers directory alongside the other scripts. For example, the Editor example, uses staff.php, which is placed here:

    [vagrant@buildvm Editor-PHP-Demo]$ ls controllers/
    cascadingLists.php  joinLinkTable.php     rest                   staff-html.php     upload-many.php
    checkbox.php        joinNested.php        searchPanes.php        staff.php          upload.php
    compoundKey.php     joinOptionsTable.php  sequence.php           staff-view.php     users.php
    countries.php       join.php              sitesNested.php        standalone.php
    dates.php           joinSelf.php          sites.php              tableOnlyData.php
    datetime.php        jsonId.php            softDelete.php         time.php
    joinArray.php       README.txt            staff-description.php  todo.php
    

    Colin

  • allanallan Posts: 54,714Questions: 1Answers: 8,560 Site admin

    It would be worth sticking to a single thread for a question, otherwise Colin and I will overlap and both get confused :).

    Allan

Sign In or Register to comment.