Click here to Skip to main content
15,884,917 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Below is my procedure:
1) Upload an excel file and then populate the data in a Grid, which shows it contains 100 records.
2) Click the "Clear" button to remove the records in the Grid and also hide the Grid.
3) Repeat Step 1) again, but the Grid displays 2 sets of 100 records. If I repeat 1) and 2) again, the Grid displays 3 sets of 100 records.
How to effectively clear the Grid? Thanks.

What I have tried:

Try to clear the Grid's records but not successful.
Posted
Updated 15-Mar-21 5:29am
Comments
Richard Deeming 15-Mar-21 8:31am    
Come on - you know the drill by now!

If you want someone to help you fix your code, you need to show the relevant parts of your code.

You can clear the grid (or anything else) by just making it go away.

First - wrap your grid in an element, like <div> and give it an ID.

To populate it, create your grid as a sting of elements and keep concatenating them.
Now, use the DOM getElementById().innerHTML and set it equal to the string.

Magic - it appears!
Set that same innerHTML to '' and it all goes away.

Another route is to create nodes create the grid and add the rows in a loop, instead of concatenation.

One final thing: in the future, if your "What I have tried:" is in that form that you used (I tried to and it didn't work) I will presume you didn't try anything. There will be no help coming.
 
Share this answer
 
v2
You are right.  I did have   $('#tableDiv')[0].innerHTML = '';  However, accidently, I commented out.  After having it back.  The problem is resolved.  Thanks.
 
Share this answer
 
Comments
Richard Deeming 15-Mar-21 11:42am    
If you want to reply to a solution, click the "Have a Question or Comment?" button under that solution and post a comment.

Do not post your comment as a new "solution".

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900