내 문제는 다음과 같다 자바 스크립트 객체를 통해 로컬 데이터를 추가
-
이 데이터가 여러 부분에서 웹 서비스에서 구문 분석 - - 내가 객체의 배열을 얻을 내가 로컬 데이터
를 표시 할 수있는 jqGrid를 사용하고 있습니다 (변경 가능)
- addJSONData, no no로 부품별로 새 데이터를 추가하려고 시도합니다.
- jqGrid 매개 변수 "data"를 데이터 부품의 병합 된 배열있는 jqGrid는
일부 시도에서는 빈 행이 표시됩니다.
포맷터를 사용하면 rowObject는 괜찮지 만 cellValue는 비어 있습니다 (정의되지 않음).
colModel과 데이터 구조가 "호환"되지 않는 것 같습니다.
그리드에 여러 부분으로 데이터를 추가하고 싶습니다.
행을 정렬하여 표시해야합니다.
{
caption: 'Villes',
data: [],
datatype: 'local',
colNames: ['Actions', 'Distance', 'Coordonnées', 'Nom', 'Joueur', 'Puissance', 'Alliance', 'Diplomatie', 'Brumes', 'Status'],
colModel: [
{name: 'actions', sortable: false, search: false, formatter: Shared.gridRowActions, width: 50},
{name: 'range', index: 'range', width: 60},
{name: 'coords', index: 'gps', sortable: false, search: false, formatter: function(cellValue, options, rowObject){ return Shared.mapLink(cellValue); }, width: 90},
{name: 'city', index: 'city'},
{name: 'player', index: 'player'},
{name: 'might', index: 'might', align: 'right', defval: 0, formatter: function(cellValue, options, rowObject){ return Shared.format(cellValue); }, width: 70},
{name: 'guild', index: 'guild'},
{name: 'diplomacy', index: 'diplomacy', formatter: function(cellValue, options, rowObject){ return Shared.getDiplomacy(cellValue); }, width: 70},
{name: 'mist', index: 'mist', align: 'center', formatter: function(cellValue, options, rowObject){ return cellValue === 1 ? 'Oui' : ''; }, width: 55},
{name: 'user', index: 'user', formatter: function(cellValue, options, rowObject){ return Shared.userStatusLink(cellValue); }}
],
pager: '#pager-cities',
loadui: 'disable',
rowNum: 20,
rowList: [20, 50, 100],
sortname: 'range',
sortorder: 'asc',
altRows: true,
autowidth: true,
viewrecords: true,
gridview: true,
multiselect: true,
multiboxonly: true,
multikey: 'shiftKey'
}
그리고 그리드에 데이터를 추가하는 코드 :
다음은 매개 변수입니다.
var merged = [];
var $grid = $('#grid);
...
merged = merged.concat(cities);
$grid.jqGrid('setGridParam', {data: merged}).trigger('reloadGrid');
는 또한 시도 :
[
{"id":338591,"cell":[2,"338,591","140","15545536","Lord Patrice02200","","0","Patrice02200",0]},
{"id":339591,"cell":[2.24,"339,591","50","16300072","Lord mercedes9pd7e","","0","mercedes9pd7e",0]},
{"id":341591,"cell":[3.61,"341,591","727714","16330552","Lord Torkan","","0","Rizane",0]},
{"id":341592,"cell":[4.24,"341,592","490","10929616","Lord pulpfiction","","0","pietra",0]}
]
내가 정말 필요로하는 유일한 가지 부분으로 데이터를로드 할 수있는 기능이며, 그리드 것을 :
$grid[0].addJSONData({page: 0, total: 0, records: cities.length, rows: cities});
데이터 배열 exemple입니다 데이터는 각 데이터 추가 후에 정렬되어 표시됩니다. 작업 호출기는 보너스가됩니다.
데모 주셔서 감사합니다. 데이터 형식을 변경할 수 있습니다. [{ "id": 338591, "range": 2, "gps": "338,591", ...}] 작동합니까? – GMO
@GMO : 서버에 별도의 Ajax 호출을 수행하여 데이터를 얻는 경우'datatype : "json"'을 사용하고 서버에서 직접 데이터를 가져 오는 것이 좋습니다. ''{ "id": 338591, "range": 2, "gps": "338,591", ...}]''datatype : "local"'의 경우 입력으로 직접 사용될 수 있습니다. – Oleg