jqGrid中添加一行數據

addRowData

官方說明:

Method parameters Returns
addRowData rowid,data, position, srcrowid true on success, false otherwise

Description:

Inserts a new row with id = rowid containing the data in data (an object) at the position 
specified (first in the table, last in the table or before or after the row specified in srcrowid).
The syntax of the data object is: {name1:value1,name2: value2…} where name is the name of the 
column as described in the colModel and the value is the value. <br>This method can insert 
multiple rows at once. In this case the data parameter should be array defined as 
[{name1:value1,name2: value2…}, {name1:value1,name2: value2…} ] and the first option rowid should
contain the name from data object which should act as id of the row. It is not necessary that 
the name of the rowid in this case should be a part from colModel.

參數有4個,分別爲,新插入的行的rowid,該行的數據(也可以一次性插入多行數據),插入數據的位置,這裏通常有firstlastbeforeafter這幾個選項,分別表示插到首,尾,前,後等位置.最後一個參數srcrowid是當position爲beforeafter時,需要指定的參照rowid.
一般而言,我們都是直接插到尾端.

$("#productList").addRowData(rowid, josnData, "last");
發佈了73 篇原創文章 · 獲贊 3 · 訪問量 2萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章