Yep, a few wee suggestions in no particular order...

1. Instead of .hide() and .show() try adding/removing the name of a
class that makes the element hidden. (Can be faster for the css engine
to do the hiding for you). Also, the toggleClass() method may be
handy.

2. The spaces in your selector each search to any depth. The child
selector ">" can often speed things up. Eg: $
("#example>tbody>tr>td.name")

3. Instead of searching for td.name on every key stroke, try putting
the list of cells into a variable before hand and refer to that inside
the event handler. Eg: $cells = $("#example>tbody>tr>td.name"). This
is likely to have the biggest impact on performance.

4. Try hiding rows instead of cells.

5. Try searching in .text() instead of .html()

6. A longshot but if each row has many cells then try filtering by
the .text() of the rows first then by cells. (Only if you cannot do
suggestion 3)

7. The moreSelectors plugin has an invert() method that can swap the
results of the last filter() action.

8. The moreSelectors plugin has a colCells() method to return cells in
a given column index.

George

On Aug 19, 6:03 pm, Potluri <[EMAIL PROTECTED]> wrote:
> Hi everyone,
>  Thanks for everyone who responded for my previous queries.
>  Here is an assignment which I feel challenging for our for our jquery guys.
> for table with 500 rows. I don't want to use any plugin for this.
>
> Well the task is when we type some thing in a text box it has to show only
> those rows which has the value typed in textbox
> in one coloumn.
>
> For ex.
> consider a table with id "example"
> <table id="example">
> <tbody>
> <tr><td> blah vijay</td></tr>
> <tr><td> blah victor</td></tr>
> <tr><td> blah avinash</td></tr>
> <tr><td> blah steven/td></tr>
> <tr><td> blah russell</td></tr>
> <tr><td> blah suresh</td></tr>
>
> </tbody>
> </table>
>
> So, when I type in "vi" in text box only rows that has vijay,victor,avinash
> should be shown, remaining should be hidden since all of them has Vi in
> their names.
>
> I did it in this way,
> let id of text box be textId
> $("#textId").keyup(function(){
> var val=$("#textId").val(); // which gives value typed in textbox
> $("#example tbody tr td.name").each(
> function()
> {
> if( $(this).html().indexOf("val") == -1)
> {
>  $(this).hide();}
>
> else  $(this).show();
>
> });
> });
>
> This works fine but it's taking 2 secs to do for table with 500 rows. Is
> there any better way to do this.
> Any staright help is appreciated.
> Thanks in advance.
>
> --
> View this message in 
> context:http://www.nabble.com/hide-table-rows-when-we-type-in-text-box-tf4294...
> Sent from the JQuery mailing list archive at Nabble.com.

Reply via email to