Solved

HTML Table filtering

Posted on 2011-09-04
3
157 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 40

Expert Comment

by:Richard Quadling
ID: 36483264
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
ID: 36489210
Do you suggest any other library? I am looking to achieve this.
0
 
LVL 40

Accepted Solution

by:
Richard Quadling earned 500 total points
ID: 36489292
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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…
Suggested Courses

626 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