Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

HTML Table filtering

Posted on 2011-09-04
3
Medium Priority
?
159 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 2000 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

Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

Question has a verified solution.

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

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
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…

670 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