Jump to content
Sign in to follow this  
henning1518

Using jquery to hide row in table

Recommended Posts

Hi,

 

i have a problem to hide rows in a table with jquery. The rows have only a text value. It works perfect with columns.

Codesample of table in cmdb_versioning_tab.htmpl:

<table width="100%" height="100%" id="cmdbVersionDetails">
.....
<tbody><tr><td class="data" valign="top"><b>123456<b></b></b></td></tr><tr class="table_banded_row"><td class="data" valign="top">Contacts</td><td class="data" valign="top">Last change by</td><td class="data" valign="top">Doe, John</td></tr><tr class="table_row"><td class="data" valign="top">Location</td></tr>
..........
</tbody></table>

Hide columns:

function hideColumns() {
	var ownerIndex = jq('th:contains("Changed by")').index();
	if(ownerIndex != -1) {
		jq("#cmdbVersionDetails tbody tr").each(function() {
			jq(this).find("td:eq(" + ownerIndex + ")").remove();
			jq(this).find("th:eq(" + ownerIndex + ")").remove();
		});

Hide rows:

function hideRows() {
	var ownerIndex = jq('tr:contains("Last changed by")').index();
	if(ownerIndex != -1) {
		jq("#cmdbVersionDetails tbody tr").each(function() {
			jq(this).find("tr:eq(" + ownerIndex + ")").remove();
		});

I've tried many many combinations..........

 

Edited by henning1518

Share this post


Link to post
Share on other sites

hi,

i havent jq experience but I tried this one and row were deleted.

jq("#cmdbVersionDetails tr:contains(\"Last changed by\")").remove();

regards, cdtj

Share this post


Link to post
Share on other sites
1 hour ago, cdtj said:

hi,

i havent jq experience but I tried this one and row were deleted.


jq("#cmdbVersionDetails tr:contains(\"Last changed by\")").remove();

regards, cdtj

Thanks that works :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Announcements

    • Gregg

      Looking for the wiki content?

      12/20/2015

      Until I can transfer the wiki content over to the new Articles, you can find the old content here: http://www.greggsmith.net/wiki.
    • Gregg

      New site logo

      01/06/2016

      A special thanks to brianshs for creating a new site logo!
×