Is there a way to filter a table by table headers

This forum is for all Flare issues not related to any of the other categories.
Post Reply
Emmazou
Jr. Propeller Head
Posts: 2
Joined: Thu Feb 04, 2016 1:49 am

Is there a way to filter a table by table headers

Post by Emmazou »

Is there a way to filter a table by table headers in frameless output? It's more like how filters work in Excel, not like sorting the table content alphabetically or in a specific order.

Thanks.
NorthEast
Master Propellus Maximus
Posts: 6365
Joined: Mon Mar 05, 2007 8:33 am

Re: Is there a way to filter a table by table headers

Post by NorthEast »

There's nothing like that built-in to Flare.

I'd strongly recommend looking at the brilliant Datatables plugin: https://www.datatables.net/

We use it in one of our projects for filtering and sorting a massive table (see here).
nielsf
Propeller Head
Posts: 86
Joined: Mon Feb 02, 2015 5:44 am
Location: Copenhagen, Denmark

Re: Is there a way to filter a table by table headers

Post by nielsf »

Very nice indeed!
I never got it to Datatables work due to conflicts with require.js and whatnot, so I wrote my own javascript table filter (sorting was not required). I found it easier to write my own than to work out how to get around require.js. :roll:
-Niels
-----
Flaring in Copenhagen, Denmark
NorthEast
Master Propellus Maximus
Posts: 6365
Joined: Mon Mar 05, 2007 8:33 am

Re: Is there a way to filter a table by table headers

Post by NorthEast »

nielsf wrote:Very nice indeed!
I never got it to Datatables work due to conflicts with require.js and whatnot, so I wrote my own javascript table filter (sorting was not required). I found it easier to write my own than to work out how to get around require.js. :roll:
-Niels
Yeah, it took me a while to work out RequireJS - to initialise it, I run a script like this.
You'd need to change
- baseUrl path : relative path from topic to datatables js file in your project
- jquery path : relative path from topic to Flare's copy of jquery in the output

Code: Select all

/* Set jquery path to Flare's installed version */
require.config({
	baseUrl: "../Resources/datatables/js/",
	paths: {
	"datatables": "jquery.dataTables.min",
	"jquery": "../../../../Resources/Scripts/jquery.min"
	}
});

requirejs(["jquery", "datatables" ], function() {
		/* requirejs - include all script dependencies */	
	
		$(document).ready(function() {
			
			/* - MUST Be 'DataTable' (case sensitive) */
			var mytable = $('#your-table').DataTable({
					
					/* your datatable configuration options go here */

			});
			
		
		});
		
});
Mike Kelley
Propeller Head
Posts: 68
Joined: Fri Aug 22, 2014 12:24 pm

Re: Is there a way to filter a table by table headers

Post by Mike Kelley »

Dave, that's been my problem with RequireJS. I have different topics at different ToC depths that all need access to my RequireJS enabled jQuery plugins. One relative path isn't sufficient for all my topics. I haven't been able to figure out a way around that. I tried just hosting another copy of jQuery 1.8.3 on my site so it was an absolute path for all my files, but then it became a second imported jQuery file and you know how that goes.

Any ideas?
NorthEast
Master Propellus Maximus
Posts: 6365
Joined: Mon Mar 05, 2007 8:33 am

Re: Is there a way to filter a table by table headers

Post by NorthEast »

Mike Kelley wrote:Dave, that's been my problem with RequireJS. I have different topics at different ToC depths that all need access to my RequireJS enabled jQuery plugins. One relative path isn't sufficient for all my topics. I haven't been able to figure out a way around that. I tried just hosting another copy of jQuery 1.8.3 on my site so it was an absolute path for all my files, but then it became a second imported jQuery file and you know how that goes.

Any ideas?
I've no ideas, other than if you're happy using an absolute path, could that not just be to the jQuery included by Flare?

Or if you have two versions of jQuery, that shouldn't be an issue provided they're configured in RequireJS.

I don't know RequireJS very well, and figuring it out this far took me ages!
jjw
Sr. Propeller Head
Posts: 133
Joined: Thu May 08, 2014 4:18 pm
Location: Melbourne

Re: Is there a way to filter a table by table headers

Post by jjw »

You can put an array of alternative paths in your path configuration. I think the intention is to allow you to fall back to a local script if a remote script is unavailable, but I've used this to include paths from topics at different depths. I don't know if there is a limit on the number of fallback paths you can provide.

Code: Select all

paths: {
fiddledeedee: path,
blah: [path1, path2]
}
See paths config fallbacks in the RequireJS docs.

J
zmtuabanna
Jr. Propeller Head
Posts: 1
Joined: Fri Jul 28, 2017 1:43 pm

Help with Datatables

Post by zmtuabanna »

I am totally new to datatables and jquery. I would like to make my simple HTML table filterable. I have tried to follow the steps described in the datatables manual, but I am finding no success. Any help is appreciated.
NorthEast
Master Propellus Maximus
Posts: 6365
Joined: Mon Mar 05, 2007 8:33 am

Re: Help with Datatables

Post by NorthEast »

zmtuabanna wrote:I am totally new to datatables and jquery. I would like to make my simple HTML table filterable. I have tried to follow the steps described in the datatables manual, but I am finding no success. Any help is appreciated.
You need to initialise the datatables plugin using RequireJS - see the previous posts in this thread.

That's how I got datatables to work - I can't offer any more help than I've already posted here.
Post Reply