jqGridに問題があります。4.6.0 行データを取得しようとすると、各データが文字列に変換されます。これらを解析して実際のintまたはboolean奇妙である何の値は、私は、カスタムフォーマッタ内rowobjectを見たときrowdataがここ JqGrid getRowdataは、行のセル値を文字列として返します
正しいが、あなたの代わりにgetLocalRow
方法を使用する必要がありますサンプルコードと私は
var myformatter = function (cellval, options, rowObject)
{
// rowObject is correct here {id: 1, Name: "test1", IsActive: true, Count: 10}
var active = rowObject.IsActive;// here active is true/false which is good
var count = rowObject.Count; // here count is 10,20,30 which is good
if(active)
{
// do what ever
}
return cellval;
}
var mydata = [
{id:1, Name: "test1", IsActive: true, Count: 10},
{id:2, Name: "test2", IsActive: false, Count: 20},
{id:3, Name: "test2", IsActive: false, Count: 30} ];
var grid = $("#list").jqGrid({
datatype: "local",
data: mydata,
height: "auto",
colNames: ['id', 'Name','Is Active','Count'],
colModel :[
{name:'id', index:'id', width:55},
{name:'Name', index:'Name', width:90},
{name:'IsActive', index:'IsActive', width:90, editable: true ,formatter:myformatter},
{name:'Count', index:'Count', width:90, editable: true}
],
pager: '#pager',
rowNum:10,
rowList:[10,20,30],
sortname: 'idcustomers',
sortorder: 'asc',
viewrecords: true,
gridview: true,
caption: 'Customers',
cellEdit: true,
cellsubmit: 'clientArray',
});
var row = $('#list').jqGrid('getRowData', 1);
// row is: {id: "1", Name: "test1", IsActive: "true", Count: "10"}
// What I was expecting {id: 1, Name: "test1", IsActive: true, Count: 10}
ありがとうございました。あなたの発言については、これはあなたが簡単に答えるようなあなたのために作成した迅速かつ汚れたデモです。しかし、私の本当のものは、よりコンパクトであり、アンフォーマットやその他のものに関して必要なものはすべて持っています。 –
@AmeteBlessed:ようこそ! – Oleg