Solved

HTML Table filtering

Posted on 2011-09-04
3
152 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
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:
RQuadling 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
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…

863 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

23 Experts available now in Live!

Get 1:1 Help Now