Solved

HTML Table filtering

Posted on 2011-09-04
3
151 Views
Last Modified: 2012-08-14
Hi,

I have used following approach to generate table filters.. The URL is specified below. (http://www.javascriptkit.com/script/script2/tablefilter.shtml
This approach does a good job, when there are no multiple column headers or if the column headers do not have any spanned columns/ or spanned rows. However, I now have a requirement, where I have one main header and some rows in between that span all columns and distinguish a group of rows...I have attached the screen shot of the same. The approach specified above does not work with the table structure i have.

Does anyone have any suggestions on how to achieve this?









test.jpg
0
Comment
Question by:Techsavy
  • 2
3 Comments
 
LVL 40

Expert Comment

by:RQuadling
Comment Utility
In looking at the properties for the table filter code, there doesn't seem to be a mechanism to define a selector so that only specific rows are selected.

Are you using multiple <thead></thead><tbody></tbody> for each block?

Can you show your HTML or a live link?


I'm looking at the mod_filter_fn property though. If there was a good example here, but from what I can tell this isn't a proper replacement for the builtin filtering.

Ideally this should be a function which is supplied the value, the <td> and the <tr> and returns true/false (or some other constant) that say include/exclude/whatever.



In playing with the first example, adding <thead> and <tbody> tags in the right place and then duplicating them ...
<table id="table1" class="mytable" >
	<thead>
		<tr>
			<th>World Regions</th>
			<th>Population ( 2007 Est.)</th>
			<th>Population % of World</th>
			<th>Internet Usage, Latest Data</th>
			<th>% Population ( Penetration )</th>
			<th>Usage % of World</th>
			<th>Usage Growth 2000-2007</th>
		</tr>
	</thead>
	<tbody>
		<tr>
			<td>Africa</td>
			<td>933,448,292</td>
			<td>14.2 %</td>
			<td>32,765,700</td>
			<td>3.5 %</td>
			<td>3.0 %</td>
			<td>625.8%</td>
		</tr>
		<tr>
			<td>Asia</td>
			<td>3,712,527,624</td>
			<td>56.5 %</td>
			<td>389,392,288</td>
			<td>10.5 %</td>
			<td>35.6 %</td>
			<td>240.7 %</td>
		</tr>
		<tr>
			<td>Europe</td>
			<td>809,624,686</td>
			<td>12.3 %</td>
			<td>312,722,892</td>
			<td>38.6 %</td>
			<td>28.6 %</td>
			<td>197.6 %</td>
		</tr>
		<tr>
			<td>Middle	East</td>
			<td>193,452,727</td>
			<td>2.9 %</td>
			<td>19,382,400</td>
			<td>10.0 %</td>
			<td>1.8 %</td>
			<td>490.1 %</td>
		</tr>
		<tr>
			<td>North America</td>
			<td>334,538,018</td>
			<td>5.1 %</td>
			<td>232,057,067</td>
			<td>69.4 %</td>
			<td>21.2 %</td>
			<td>114.7 %</td>
		</tr>
		<tr>
			<td>Latin America / Caribbean</td>
			<td>556,606,627</td>
			<td>8.5 %</td>
			<td>88,778,986</td>
			<td>16.0 %</td>
			<td>8.1 %</td>
			<td>391.3 %</td>
		</tr>
		<tr>
			<td>Oceania / Australia</td>
			<td>34,468,443</td>
			<td>0.5 %</td>
			<td>18,430,359</td>
			<td>53.5 %</td>
			<td>1.7 %</td>
			<td>141.9 %</td>
		</tr>
	</tbody>
	<thead>
		<tr>
			<th>World Regions</th>
			<th>Population ( 2007 Est.)</th>
			<th>Population % of World</th>
			<th>Internet Usage, Latest Data</th>
			<th>% Population ( Penetration )</th>
			<th>Usage % of World</th>
			<th>Usage Growth 2000-2007</th>
		</tr>
	</thead>
	<tbody>
		<tr>
			<td>Africa</td>
			<td>933,448,292</td>
			<td>14.2 %</td>
			<td>32,765,700</td>
			<td>3.5 %</td>
			<td>3.0 %</td>
			<td>625.8%</td>
		</tr>
		<tr>
			<td>Asia</td>
			<td>3,712,527,624</td>
			<td>56.5 %</td>
			<td>389,392,288</td>
			<td>10.5 %</td>
			<td>35.6 %</td>
			<td>240.7 %</td>
		</tr>
		<tr>
			<td>Europe</td>
			<td>809,624,686</td>
			<td>12.3 %</td>
			<td>312,722,892</td>
			<td>38.6 %</td>
			<td>28.6 %</td>
			<td>197.6 %</td>
		</tr>
		<tr>
			<td>Middle	East</td>
			<td>193,452,727</td>
			<td>2.9 %</td>
			<td>19,382,400</td>
			<td>10.0 %</td>
			<td>1.8 %</td>
			<td>490.1 %</td>
		</tr>
		<tr>
			<td>North America</td>
			<td>334,538,018</td>
			<td>5.1 %</td>
			<td>232,057,067</td>
			<td>69.4 %</td>
			<td>21.2 %</td>
			<td>114.7 %</td>
		</tr>
		<tr>
			<td>Latin America / Caribbean</td>
			<td>556,606,627</td>
			<td>8.5 %</td>
			<td>88,778,986</td>
			<td>16.0 %</td>
			<td>8.1 %</td>
			<td>391.3 %</td>
		</tr>
		<tr>
			<td>Oceania / Australia</td>
			<td>34,468,443</td>
			<td>0.5 %</td>
			<td>18,430,359</td>
			<td>53.5 %</td>
			<td>1.7 %</td>
			<td>141.9 %</td>
		</tr>
	</tbody>
</table>

Open in new window


And then running the filter for Asia, the second <thead> is filtered out.

Not what should happen.

So, the code is not looking at headers.

Having said that, if the body rows were filtered out, should the headers remain?


I don't think this particular library is up to your needs.

0
 

Author Comment

by:Techsavy
Comment Utility
Do you suggest any other library? I am looking to achieve this.
0
 
LVL 40

Accepted Solution

by:
RQuadling earned 500 total points
Comment Utility
I've not needed to filter data like that.

But, considering that the filtering is nearly right, I'd go to the author and ask if there are any updates? Tell him your issues. See what he says.

0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

This article discusses how to create an extensible mechanism for linked drop downs.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now