Json를 다음과 같이 리털할 경우
{ "page":"1", "total":2, "records":"13", "user":[ {"id":"12345","name":"Desktop Computers","email":"josh@josh.com","item":{"price":"1000.72", "weight": "1.22" }, "note": "note", "stock": "0","ship": "1"}, {"id":"23456","name":"<var>laptop</var>","note":"Long text ","stock":"yes","item":{"price":"56.72", "weight":"1.22"},"ship": "2"}, {"id":"34567","name":"LCD Monitor","note":"note3","stock":"true","item":{"price":"99999.72", "weight":"1.22"},"ship":"3"}, {"id":"45678","name":"Speakers","note":"note","stock":"false","ship":"4"} ] }
리스트를 표출하는 소스에서는 다음과 같이 처리함
jQuery(
function()
{
jQuery("#list2").jqGrid({
url:'/admin/user/list/json',
datatype: "json",
jsonReader : {
page: "page",
total: "total",
root: "user",
records: function(obj){return obj.length;},
repeatitems: false,
id: "seq_user"
},
colNames:['seq_user','Date', 'Client', 'Amount','name','Total','Notes'],
colModel:[
{name:'seq_user',index:'seq_user', width:55},
{name:'invdate',index:'invdate', width:90},
{name:'name',index:'invdate', width:100},
{name:'amount',index:'amount', width:80, align:"right"},
{name:'name',index:'name123123', width:80, align:"right"},
{name:'total',index:'total', width:80,align:"right"},
{name:'note',index:'note', width:150, sortable:false}
],
rowNum:10,
rowList:[10,20,30],
pager: '#pager2',
sortname: 'seq_user',
viewrecords: true,
sortorder: "desc",
caption:"JSON Example"
});
jQuery("#list2").jqGrid('navGrid','#pager2',{edit:false,add:false,del:false});
}
);
'Front-End > jQuery' 카테고리의 다른 글
jQuery Tree메뉴 간단하게 만들기 (0) | 2012.07.09 |
---|---|
[jqgrid] cell 값 수정 할 때 넘어가는 rowid 값 설정 (0) | 2012.07.09 |
delegate & live 간단예제 (0) | 2012.06.25 |
jQuery img 경로 오류 시 대체 이미지 설정하기 (엑박 방지) (0) | 2012.06.21 |
jQuery ready(fn) vs load(fn) (0) | 2012.04.30 |