将数据映射到jqGrid

问题描述

如何将数据作为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创建后无法更改。 一种可能的解决方案是使所有可能的列都具有,然后按条件显示/隐藏某些内容。

您可以在此处放置服务器响应和网格配置,以查看问题所在

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...