问题描述
如何将数据作为Map发送到jqgrid?
后端:
List<Map<String,Object>> rows = new ArrayList<>();
Map<String,Object> data = new HashMap<String,Object>();
data.put("code","ONE");
data.put("libelle","ONELibelle");
data.put("titre","ONEValeurCarac");
Map<String,Object> data2 = new HashMap<String,Object>();
data2.put("code","ONE2");
data2.put("libelle","iONELibelle2");
data2.put("titre","ONEValeurCarac2");
Map<String,Object> data3 = new HashMap<String,Object>();
data3.put("code","ONE3");
data3.put("libelle","ONELibelle3");
data3.put("titre","ONEValeurCarac3");
rows.add(data);
rows.add(data2);
rows.add(data3);
Gson gson = new Gson();
String datajson = gson.toJson(rows);
我将变量datajson作为数据发送到接收方(varColModel:code,libelle,titre)
var myGrid = $("#jqgrid").jqgrid({
url : myurl,datatype : "json",mtype : 'POST',colModel : varColModel,headertitles : true,rowNum : 50,scrollOffset:50,sortname : 'code',sortorder : 'asc',
网格为空。
解决方法
colModel创建后无法更改。 一种可能的解决方案是使所有可能的列都具有,然后按条件显示/隐藏某些内容。
您可以在此处放置服务器响应和网格配置,以查看问题所在