开发者

jqgrid delete all rows inside grid

开发者 https://www.devze.com 2023-03-01 12:24 出处:网络
Is there a way to delete all rows in one function call? and not by looping through all rows and deleting row by row.

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.开发者_运维知识库


If you mean remove all rows from the grid you can just do this..

$('#grid1').jqGrid('clearGridData');


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);


If you're going to remove all rows and insert grid data back, you may use $('#grid1').jqGrid('GridUnload'); Otherwise, you can use old answer suggested by Oleg

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号