En cliquant sur un bouton, je suis en train de charger le jqGrid avec JSON datadtype. J'ai essayé de nombreuses façons de charger des données, mais elles échouent et affichent une grille vide. S'il vous plaît aviser ce que je manque ici.Json données ne se charge pas en jqGrid avec ressort 3 mvc
Ma grille
$("#bedata").click(function(){
jQuery("#list2").jqGrid({
url:'/mso/interop/interopcompanycfg/getDSAccounts?companyId=${interopcompcfg.company.id}',
datatype: "json",
mtype: 'GET',
colNames:['Id','DTCCID','COMPANYID','DTCCACCOUNTID'],
colModel:[
{name:'ID',index:'id', sortable:true, align:'center',width:90},
{name:'DTCCID',index:'dsId', sortable:true, align:'center',width:90},
{name:'COMPANYID',index:'companyId',sortable:true, align:'center', width:120},
{name:'DTCCACCOUNTID',index:'dsLegalEntityId', sortable:true, align:'center',width:130}
],
rowNum:10,
rowList:[10,20,30],
pager: '#pager2',
sortname: 'dsId',
viewrecords: true,
sortorder: "desc",
caption:"DS ACCOUNTS",
jsonReader: {
repeatitems : false,
root:"rows",
cell: "",
id: "0"
}
});
jQuery("#list2").jqGrid('navGrid','#pager2',{edit:true,add:true,del:true});
});
spring requestmapping
@RequestMapping(value="/getDSAccounts",method= RequestMethod.GET)
public @ResponseBody List<Vector<String>> getDSAccountsJSON(HttpServletRequest request,HttpServletResponse httpResponse) {
try{
UsersJsonDTO usersJsonDTO = new UsersJsonDTO();
usersJsonDTO.setPage("1");
usersJsonDTO.setRecords("8");
usersJsonDTO.setTotal("20");
Company cmp=(Company) request.getSession().getAttribute("company");
List<DSAccounts> message = interopService.getDSAccounts(cmp);
httpResponse.setContentType("text/javascript");
int i=0;
List<DTCCAccounts> rowJsonList = new ArrayList<DTCCAccounts>();
for (DSAccounts dsAccountDTO:message)
{
DTCCAccounts rowJson = new DTCCAccounts();
rowJson.setId(String.valueOf(i+1));
rowJson.setDsId(String.valueOf(dsAccountDTO.getDsId()));
rowJson.setCompanyId(String.valueOf(dsAccountDTO.getCompany().getId()));
rowJson.setDsLegalEntityId(dsAccountDTO.getDsLegalEntityId());
rowJsonList.add(rowJson);
}
usersJsonDTO.setRows(rowJsonList);
return usersJsonDTO;
Pouvez-vous poster votre JSON afin que nous puissions valider? Vous pouvez également le valider vous-même en utilisant http://www.jsonlint.com/ – thomaspaulb
J'ai vérifié sur jsonlimt.com et le Json est valide.{ "page": "1", "records": "8", "lignes": [ { "COMPANYID": "1661", "DSID": "72", "dsLegalEntityId": "SELLSIDE01", "id": "1" }, { "COMPANYID": "1661", "DSID": "74", "dsLegalEntityId": "SELLSIDE03", "id": " 1 " } ], " total ":" 20 " } – Sabari
Je suppose que le jsonmapping dans colModel est à l'origine du problème ... mais pas de documentation ou d'exemples disponibles. un indice ou un lien de support serait d'une grande aide – Sabari