Ajax 重新绑定 webgrid 数据,如何修改AJAX调用在jqGrid中呈现之前返回的数据?

我设法弄清楚如何去做。而不是让jqGrid自动加载数据,需要手动执行请求,然后通过调用addJSONData加载它。

我的jqGrid在标记定义了如下:

我初始化用下面的代码网格:

// Initialize the grid

this._searchResults = this._dialog.find("#eventSearchDialog-results");

this._searchResults.jqGrid(

{

datatype: "local",

colNames: ['', 'Event Name', 'Event Type', 'Start Date', 'End Date', 'Location', 'Event Country', 'Sports'],

colModel: [

{ name: 'selector', index: 'selector', width: 30 },

{ name: 'EventName', index: 'EventName', formatter: jqgridCellFormatter, width: 150 },

{ name: 'EventType', index: 'EventType', formatter: jqgridCellFormatter, width: 120 },

{ name: 'StartDate', index: 'StartDate', formatter: jqgridCellFormatter, width: 100 },

{ name: 'EndDate', index: 'EndDate', formatter: jqgridCellFormatter, width: 100 },

{ name: 'Location', index: 'Location', formatter: jqgridCellFormatter, width: 100 },

{ name: 'EventCountry', index: 'EventCountry', formatter: jqgridCellFormatter, width: 100 },

{ name: 'Sports', index: 'Sports', formatter: jqgridCellFormatter }

],

rowNum: 10,

rowList: [10, 20, 30],

pager: this._dialog.find("#eventSearchDialog-pager"),

pginput: true,

sortname: 'EventName',

viewrecords: true,

sortorder: "asc",

hidegrid: false,

height: "auto",

shrinkToFit: true,

width: 630,

jsonReader:

{

page: "pageIndex",

total: "pageCount",

records: "recordCount",

root: "rows",

repeatitems: true

},

prmNames:

{

page: "pageIndex",

rows: "pageSize",

sort: "sortField",

order: "sortOrder"

}

}

);

// Set the data type to JSON, we don't do this in the options because it will cause a request to occur,

// but we do need it to be set to JSON so that the calls to addJSONData work later.

this._searchResults.jqGrid("setGridParam", { datatype: "json" });

我从一个jQuery $.ajax()呼叫负载与数据的网格,和在success事件处理程序中,我填充数据,然后使用addJSONData将其加载到jqGrid中。

我的JSON是这样的:

{

"pageCount":1,

"pageIndex":1,

"recordCount":2,

"rows":

[

{"id":3, "cell":["Stevens Event 2", "Commonwealth Games", "03/05/2011", "16/05/2011", "sersdfweqr", "New Zealand", ["Archery"]]},

{"id":4, "cell":["Test - multiple sports", "Other", "01/05/2011", "30/06/2011", "Kobe", "Japan", ["Judo", "Karate", "Motor Sport", "Motorcycling", "Taekwondo"]]}

]

}

这是我success处理程序:

success: function (data, textStatus, xhr) {

// Pad data for our radio button column that has no corresponding field in the data

for (var counter = 0; counter < data.rows.length; counter++) {

data.rows[counter].cell.splice(0, 0, null);

}

thisEventSearchDialog._searchResults[0].addJSONData(data);

thisEventSearchDialog._createRadioButtons();

},

包含需要将假数据用于其单选按钮的列中的jqGrid的。没有虚拟数据,行数据与标题不匹配。

SESmo.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值