"Custom HTTP variables" example - with predefined selection
"Custom HTTP variables" example - with predefined selection
I am developing a replacement for a WordPress site, using DataTables for several of the pages. The data relates to revisions to bus service timetables, and has two main tables - one with details of the routes, and the second with records of the individual changes to the timetables. The routes table has almost 50,000 records, and the timetable changes table has about 200,000 - so the data is handled on the server.
My question relates to the page entitled "Local authority code list" ( https://ba4.nwframpton.com/local-authority-code-list.php/ ). This page lists the local authority areas for which we have data, with a 4-character code, and a link, which should take the user to a page containing a list of bus services serving the selected authority area - i.e. a filtered version of the complete list of all services. The code associated with the link buttons includes the corresponding 4-character authority code, and takes the user to a page named "Search for routes by selected authority" ( https://ba4.nwframpton.com/search-for-a-route-selected-auth.php/?search_column_brghs=MDWY ). The value of the search_column_brghs parameter varies, dependent on which local authority has been selected on the code list page; and the code is also shown at the top left corner of the routes page (as a temporary measure for debugging purposes).
The "Search for routes by selected authority" page has been constructed based on your example "Custom HTTP variables" ( https://datatables.net/examples/core/server_side/custom_vars.html ), and the filter functions correctly if the user enters the 4-character authority code into the box marked "Office column filter" at the upper left are of the page. However, I want to automate the filtering on this page, so that the data will be automatically be filtered as soon as the page opens.
I can add a "value=$search_parameter" setting to the code for the input box (
Office column filter:
) - for example, <input id="officeFilter" value=$search_index></p> - but this does not give the correct results. If I hard code a specific valid authority code - for example, <input id="officeFilter" value='MDWY'></p>, then this filter is applied correctly - but I need to enable the users to select the other authorities as well.
I guess that it may also be possible to transfer the filter value more directly, and thereby avoid the need to include the office column filter input box altogether. This would seem to be a neater solution, but would presumably need some changes to the JavaScript and/or the JSON encode on the server-side processing script?
Thanks in advance for any advice that you can give.
Nigel Frampton
Replies
Does the solution discussed in the Deeplinking blog do what you want?
Kevin
Hmmm - that blog post isn't going to do much of what any one wants at the moment! I haven't updated it for DataTables 3. I'll need to go back over the old blog posts and update them unfortunately.
I have updated the Deep Linking plug-in already though. If the text in the blog post describes what you need, take a look at the plugin here.
Allan
That specific blog post has been updated now. I'll work through the others at some point.
Allan
Allan and Kevin - Thank you for your prompt assistance.
I think the "Deep linking" blog post is relevant, since it refers to "...applications where you want to show a table with a specific search term pre-set." However, I shall have to check whether I can set npm up on my hosting service. It might already be available, but I cannot generally make use of command line access.
Nigel