Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4620578
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:34:46+00:00 2026-05-22T02:34:46+00:00

I need solution of auto hide/remove table-rows of deleted records. Suppose a table-body element

  • 0

I need solution of auto hide/remove table-rows of deleted records.

Suppose a table-body element with id ‘tbody’ and table-rows (tr) with records’ id:

<table>
<tbody id="tbody">
@foreach (var user in Model) {
    
    <tr id="@user.ID">
        <td>@user.ID</td>
        <td>@user.FullName</td>
    </tr>        
}
    </tbody>
</table>

Here is the code to update new rows in the same table, but my question is how to delete/hide rows:

$.ajax( {
        url: '/Controller/Action',
        type: 'post',
        success: function ( result )
        {
            if ( result.length >= $( '#tbody' ).find( 'tr' ).length )
            {
                $.each( result, function ( i, v )
                {
                    if ( !$( 'tbody tr#' + v.ID ).length )
                    {
                        $( '# tbody' ).append( 
                              '<tr id="' + v.ID + '">'
                            + '<td>' + v.FullName + '</td>'
                            + '</tr>' );
                    }
                } );
            }
            else
            {
        /*
            It seems that one or more records in the 'result' object
            is deleted/removed.
       
            Compare table rows and the 'result' object’s records.
            Delete/hide all rows that are not found/matched in 'result' object.
        */   

            }
        }
    } );

I want to put some code in the ‘else’ block to hide rows that do not exist in the ‘result’ object.

And the object I’m calling looks like this:

var result = new
{
    ID = 1,
    FullName = "Muaz Khan"
};

I myself tried following technique to hide the rows of deleted records:

else {
    $.each( result, function ( i, v )
        {
             if ( $( '#tbody tr#' + v.ID ).length ) // if exist
             {
                  $( '#tbody tr#' + v.ID ).addClass( 'not-deleted' );
             }
             // hide all rows with no class: 'not-deleted'
        // $(‘#tbodytr’).notHasClass(‘not-deleted’).hide();
        } );
}

There is no method ‘notHasClass’. Also, this is not a good workaround.

I also played with a lot of jquery selectors like :not() etc. but vain. I also unable to take advantage of hasClass() jquery method.

So the last workaround left is to show anchor-link or button element and to prompt the end-user to click to refresh the full-table rows. It’s too bad. I need a solution for auto hide rows of deleted records.

Also, please bear in mind that I don’t want to refresh the whole table. It’s too bad to play with DOM if you have other choices.

Can you let me know how to delete appropriate table rows; table rows of the records that are deleted.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T02:34:47+00:00Added an answer on May 22, 2026 at 2:34 am

    You should use jQuery remove method to delete particular DOM element.

    Like

    $( '#tbody tr#' + v.ID ).remove();
    

    http://api.jquery.com/remove/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need a solution for auto-adjusting the width and height of an iframe to
I'm looking for a quick cross browser solution to my need for auto margins.
I have a table of around 30 rows. I need to insert a new
I have a SELECT element in which I need to auto-select the appropriate option
I have solution where i need that id in one table starts every month
I need a solution for the really common but important issue that i am
I need a solution for a conditional WHERE clause in SQL Server. I can't
I need a solution to embed a pdf inside a flash screen i.e. want
I need a solution for caching PHP info on a dynamic page AND include
Simple question: I need a solution so that I can find, lets say names,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.