【发布时间】:2011-12-16 15:49:51
【问题描述】:
我有这段代码只是为了从已经加载的 jqGrid 发送数据:
jQuery("#bedata").click(function(){ //Function for button "bedata"
var postData = "SOME DATA TO SEND"
//Sending data:
$.ajax({
type: "POST";
url: "GuardaFila.action", //Action called to data treatament (Struts 2)
data : {
jgGridData: postData, //PARAMETER jgGrdData with variable "postData" value
customData: "someinfo" //Just another parameter called "customData" with more data,
},
dataType:"json",
contentType: "application/x-www-form-urlencoded; charset=utf-8",
//Success function has the key that I am looking for:
success: function(response, textStatus, xhr) {
//SOME CODE HERE TO REFILL jqGrid.
alert("success");
},
error: function(xhr, textStatus, errorThrown) {
alert("error");
}
});
});
jqGrid之前已经通过这种方式创建了:
jQuery("#rowed3").jqGrid({
url:'CargaTabla.action',
datatype: "json",
colNames:['id', 'Direccion', 'Nombre'],
colModel:[
{name:'id',index:'id', width:55},
{name:'direccion',index:'direccion', width:90, editable:true},
{name:'nombre',index:'nombre', width:100,editable:true}
],
jsonReader: {
root: 'gridModel',
id: '0',
cell :"",
repeatitems: false
},
(....... etc)
所以,jqGrid 表的 id 是#rowed3。我知道在ajax函数中:
success: function(response, textStatus, xhr) {
//SOME CODE HERE TO REFILL jqGrid.
alert("success");
},
response 参数有一个新的 JSON 格式的网格内容。我尝试了一些方法来用它的数据重新填充网格,因为它的“datastr”参数设置了它的内容和其他参数。有人遇到过这个问题吗?
谢谢。
【问题讨论】: