NOTE: changing:
$(this).closest("tr").prev
to:
$(this).closest("tr").togg
will show/hide the rows whenever you check/uncheck the checkbox.
Main Topics
Browse All TopicsHello,
I need help with a jquery function...
I have table (view png for example) and there are rows and related rows that relate to an original row, so row 1 with data and row 1a, with status of of void. There is also a checkbox above the table that when clicked will hide the row and related row that have action of void. So essentially hide any row that has action status of void and the related row or corresponding row. The related row should normally be above the voided row, but may not always be right on top of each other, as sorting will be ascending related rows will always be above rows with void status.
I am new to javascript and jquery, so any code or examples you can provide, would be much appreciated. If I could double the points awarded I would...
here is something that a friend gave me that might help get started.
When the "Hide voided items" box is checked, we not only hide the rows that contain Action = Void, but also the related row that was voided. In the example below, each yellow voided row is related to red row directly above it.
NOTE: Related rows will not always be located DIRECTLY above the Void row, but they will ALWAYS be ABOVE the Void row because the table is always sorted by Date ascending. Void can only be related to something that's already occurred.
You need to write a script using JQuery where its useful to streamline code, and/or with standard Javscript. What's important is to make the script with a few as lines as possible. Unless you can come up with a better alternative, and I encourage you to consider all possibilities, I think your script should be based on the following logic:
hideVoid(){
get the Activity Log table
go to last row and begin traversing the rows in reverse order
looking for a row where column #2 innerHTML = "Void"
if true, remember the row num
continue traversing up the table looking for the row that relates to our Void row
if the next row is not a Void row, see if it's a related row
to match a related row, see if column 1, column 3, column 4, AND column 5 innerHTML = same innerHTML from our Void row (all must match)
hide the related row and the Void row
continue traversing up the table looking for any more Void rows
if we find another Void, repeat the process to find related row
]
Thank you, much appreciated for your help!!
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Hielio, is there a way to have this whole script written in Jquey or is there a way trim the script down to a s little as possible, we would like to have as few lines as possible. Currently as how to relate, what we are wanting is this...on load the table will display the payment details row and if there was a voide related to that payment details that will also be displayed. Most of the time these will adjacent to each other, but there may be times that they will be separated as more details may be entered before the void is actually performed. For this reason when you click the void items box to hide both the payment details and related voided item, we would like it to compare the Code, Description, Amount & Payment ID columns. So if there are rows that have the same code, description, amount, payment id and one has the action of void, then both the void and regular row would both be hidden or "filtered out" when clicking the checkbox...Now to add another problem there may be times that a "notes" row will also be added using a class of datacell2. If there is a notes row, these would also need to be hidden upon check of the checkbox, I hope you understand what I am trying to explain... Let me know if you have any other questions.
I appreciate all the help as newbie to javascript and Jquery, not sure I could this without your help.!!!
Thank Youu
Solved issue with original post, thank you for the help... I will accept, so that you are awarded the points as you have helped me in the past....I am also going to post a new question to have the entire script converted to Jquery if possible to shorten the amount of code that is then loaded.
Thanks again!!
Business Accounts
Answer for Membership
by: hieloPosted on 2009-08-21 at 15:26:37ID: 25156422
>>NOTE: Related rows will not always be located DIRECTLY above the Void row, but they will ALWAYS be ABOVE the Void row because the table is always sorted by Date ascending. Void can only be related to something that's already occurred.
That makes no sense.
Here's why: On the image you posted, both yellow rows are identical, except for the date. The same goes for the pink rows. So strictly speaking the FIRST pink row IS above the LAST yellow row. So from what you described, they can be interpreted as "related" since they do NOT have to be immediately above each other. You need to find a way to designate "relatedness" without there being confusion as to how these rows are related.
IF the pink and yellow rows were always adjacent, and the yellow row always below the pink row, you could use:
Select allOpen in new window