Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
87
rated 0 times [  92] [ 5]  / answers: 1 / hits: 24987  / 13 Years ago, thu, april 28, 2011, 12:00:00

Is there a way to delete all rows in one function call? and not by looping through all rows and deleting row by row.



Thank's In Advance.


More From » jqgrid

 Answers
38

It's depend on what you exactly mean under deleting of all rows. The method GridUnload could be very helpful in many cases, but it delete more as only grid contain.



Another method used intern in jqGrid is:



var trf = $(#list tbody:first tr:first)[0];
$(#list tbody:first).empty().append(trf);


Probably it is what you need. It delete all grid rows excepting of the first one. You can overwrite the code also as the following



var myGrid = $(#list); // the variable you probably have already somewhere
var gridBody = myGrid.children(tbody);
var firstRow = gridBody.children(tr.jqgfirstrow);
gridBody.empty().append(firstRow);

[#92505] Wednesday, April 27, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
deanna

Total Points: 84
Total Questions: 86
Total Answers: 107

Location: Cyprus
Member since Wed, Dec 8, 2021
3 Years ago
;