我有一個的jqGrid與已嵌套對象JSON數據工作。我使用jsonmap來設置colmodel,它工作正常;但是當我嘗試編輯一行時,JSON傳遞到服務器只包含jsonmap財產,而不是整個對象,所以它不能夠將JSON映射到Java對象。嵌套對象的jqGrid
的JSON看起來是這樣的:
{'id': 1,
'name': 'blah',
'importantData':
{'importantDataId': 145,
'importantDataName': 'bleh'}
}
的jqGrid的colmodel看起來是這樣的:
{name:'id', label:'ID', editable: false},
{name:'name', label:'Name', editable: true},
{name:'importantData_name', label:'Important Data', jsonmap: 'importantData.importantDataName', editable: false}
請參閱importantData不可編輯,但在網格中顯示和形式。
正如我寫的,這個工作不錯,我看「的Bleh」中的「重要數據」列中的值。 當我CLIC導航欄網格的編輯按鈕時,我看到的形式與當前值編輯數據。 ID不顯示(因爲它不可編輯),而importantData顯示爲「bleh」。我在形式更改名稱和保存,發送到服務器的JSON看起來是這樣的:
{'id': 1,
'name': 'newName',
'importantData_name', 'bleh'}
服務器,因爲它希望接收整個對象importantData或至少其ID無法解析此JSON 。
我配置了一個serializeEditData函數來檢索從電網整體對象,並添加到JSON整個對象或德ID,但我不能讓整個importantData對象。任何想法?
提前致謝!