[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 164
  • Last Modified:

HTML Table filtering

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
Techsavy
Asked:
Techsavy
  • 2
1 Solution
 
Richard QuadlingSenior Software DeveloperCommented:
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
 
TechsavyAuthor Commented:
Do you suggest any other library? I am looking to achieve this.
0
 
Richard QuadlingSenior Software DeveloperCommented:
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

[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now