を並べていない私は、インライン編集とjqgridを実装しました:jqgridインライン編集行とデータが
var lastSel;
jQuery(document).ready(function() {
jQuery("#list").jqGrid({
url: '/Home/DynamicGridData/',
datatype: 'json',
mtype: 'POST',
colNames: ['Actions', 'Id', 'note', 'tax'],
colModel: [
{name:'act',index:'act',width:55,align:'center',sortable:false,formatter:'actions',
formatoptions:{
keys: true, // we want use [Enter] key to save the row and [Esc] to cancel editing.
onEdit:function(rowid) {
alert("in onEdit: rowid="+rowid+"\nWe don't need return anything");
},
},},
{ name: 'Id', index: 'Id', width: 55,align:'center', editable: false },
{ name: 'note', index: 'note', width: 40,align:'center', editable: true },
{ name: 'tax', index: 'tax', width: 40,align:'center', editable: true}],
pager: jQuery('#pager'),
rowNum: 10,
rowList: [5, 10, 20, 50],
sortname: 'Id',
sortorder: "desc",
viewrecords: true,
imgpath: '',
caption: 'My first grid',
editurl: '/Home/Save/'
});
jQuery("#list").navGrid('#pager', { edit: false, search: false, add: false });
});
問題が期待どおりに動作していないということです。問題は、グリッドが読み込まれてIdデータが「アクション」列にロードされたときに、ノートデータがID列に追加され、税データがノート列に追加されることです。税の列は空です。これは、データがロードされたときに現在アクションの列に何もないためだと思いますか?
とにかく、アクションアイコンボタンが読み込まれたときに、アクション列に正しく読み込まれていて、間違った列にあるIDデータの上に表示されます。
これを他の作業例と比較しましたが、これまでに問題が見つかりませんでした。
EDIT:
は、ちょうどこの問題は、JSONデータではなく、ローカルデータで発生発見しました。
あなたはそれをのようなJSONデータフィードのであれば:
public JsonResult DynamicGridData2(string sidx, string sord, int page, int rows)
{
int totalPages = 1; // we'll implement later
int pageSize = rows;
int totalRecords = 3; // implement later
var jsonData = new {
total = totalPages,
page = page,
records = totalRecords,
rows = new[]{
new {id = 1, cell = new[] {"1", "Note1", "Tax1"}},
new {id = 2, cell = new[] {"2", "Note2", "Tax2"}},
new {id = 3, cell = new[] {"3", "Note3", "Tax3"}}
}
};
return Json(jsonData);
}
をエラーが発生します。ただし、次のようなローカルデータを指定した場合:
data: mydata,
datatype: 'local',
var mydata = [
{id:"1", note:"Note1", tax:"Tax1"},
{id:"2", note:"Note2", tax:"Tax2"},
{id:"3", note:"Note3", tax:"Tax3"}
]
いいです。