• Resolved Fabbstar

    (@fabbstar)


    Hi there,

    I’m not sure if it already has this feature, but it would be a great addition if not.

    We have a long list of rows and it would be great to be able to search the table with the search feature already built in but then capture the search string via a URL.

    For example, I search for “Volvo” and the table displays all rows with Volvo. The url in my web browser then shows http://www.cars.com/car-search/s=Volvo which I can then use to share with customers and on other site and on social media.

    Thanks,
    Simon

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author MyThirdEye

    (@mythirdeye)

    Hey Simon,

    Unfortunately, this feature is not part of the plugin, however I will add this to the feature request list. In the meantime, if you are comfortable with editing js files, you can add the following code to the jtrt-responsive-tables-public.js file on line 125:

    if(getParameterByName('jtrt_dt_search') != undefined){ jtrtDTcopy.search(getParameterByName('jtrt_dt_search')).draw();}

    then you need to create a function called getParameterByName which was taken from of StackOverflow 😀

    
    function getParameterByName(name, url) {
    			if (!url) {
    			url = window.location.href;
    			}
    			name = name.replace(/[\[\]]/g, "\\$&");
    			var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
    				results = regex.exec(url);
    			if (!results) return null;
    			if (!results[2]) return '';
    			return decodeURIComponent(results[2].replace(/\+/g, " "));
    		}
    

    I’ve created a simple gist with the changes, so if you want just copy paste the contents of the following gist into the jtrt-responsive-tables-public.js file and save changes.

    https://gist.github.com/JohnTendik/9dc579512a20a86b830779ed477efd4c

    now you can filter your table on load when you have the following url parameter:

    http://mywebsite.com/jttablepage/?jtrt_dt_search=volvo

    Hope this helps.

    Thanks for using my plugin and offering suggestions 😀 I’m always looking for ways to improve. Let me know if there is anything else I can help you with.

    John

    • This reply was modified 9 years, 2 months ago by MyThirdEye.
    Plugin Author MyThirdEye

    (@mythirdeye)

    Plugin Author MyThirdEye

    (@mythirdeye)

    My reply disappeared for some reason, here is a copy paste hopefully this works. WP forums wont let me add the comment.

    Hey Simon,

    Unfortunately, this feature is not part of the plugin, however I will add this to the feature request list. In the meantime, if you are comfortable with editing js files, you can add the following code to the jtrt-responsive-tables-public.js file on line 125:

    if(getParameterByName('jtrt_dt_search') != undefined){ jtrtDTcopy.search(getParameterByName('jtrt_dt_search')).draw();}

    then you need to create a function called getParameterByName which was taken from of StackOverflow 😀

    
    function getParameterByName(name, url) {
    			if (!url) {
    			url = window.location.href;
    			}
    			name = name.replace(/[\[\]]/g, "\\$&");
    			var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
    				results = regex.exec(url);
    			if (!results) return null;
    			if (!results[2]) return '';
    			return decodeURIComponent(results[2].replace(/\+/g, " "));
    		}
    

    I’ve created a simple gist with the changes, so if you want just copy paste the contents of the following gist into the jtrt-responsive-tables-public.js file and save changes.

    https://gist.github.com/JohnTendik/9dc579512a20a86b830779ed477efd4c

    now you can filter your table on load when you have the following url parameter:

    http://mywebsite.com/jttablepage/?jtrt_dt_search=volvo

    Hope this helps.

    Thanks for using my plugin and offering suggestions 😀 I’m always looking for ways to improve. Let me know if there is anything else I can help you with.

    John

    Thread Starter Fabbstar

    (@fabbstar)

    Hi John,

    That’s amazing I’m going to try this tomorrow and will let you know!

    If it works it’s going to make sharing data in the table so easy.

    Thanks again,
    Simon

    Plugin Author MyThirdEye

    (@mythirdeye)

    No problem 😛 Glad I could help!

    Thread Starter Fabbstar

    (@fabbstar)

    Hi John,

    Unfortunately, having saved over the original JS file with the GIS code you provided, it doesn’t seem to filer by the URL.

    Try:

    http://www.simonlyplans.com/sim-only-deals/?jtrt_dt_search=o2

    You’ll see it doesn’t filter the table by “o2”.

    Thanks,
    Simon

    Thread Starter Fabbstar

    (@fabbstar)

    Something really weird with Support Forums at the moment.

    It says you have replied since my last comment, but no reply is shown here!

    Plugin Author MyThirdEye

    (@mythirdeye)

    Hey @fabbstar,

    I had done that example using datatables, so using responsive options “scroller” or “stack”, using the hiding columns option will use a different table script which is footables. I will look into whether or not this is possible and get back to you.

    Thanks
    John

    Plugin Author MyThirdEye

    (@mythirdeye)

    Hey @fabbstar,

    Can you try the new gist, it will include footable filter with the url as well.
    Hope this helps 😀

    https://gist.github.com/JohnTendik/9dc579512a20a86b830779ed477efd4c

    John

    Thread Starter Fabbstar

    (@fabbstar)

    YOU DID IT!!! AMAZING.

    Thanks John.

    Make it a default feature, great thing!

    Simon

    Plugin Author MyThirdEye

    (@mythirdeye)

    No problem, glad I could help! 🙂 I’ll include this feature in the update.

Viewing 11 replies - 1 through 11 (of 11 total)

The topic ‘Adding Search String to URL’ is closed to new replies.