【问题标题】:Map DATA to jqGrid将 DATA 映射到 jqGrid
【发布时间】:2021-01-09 11:38:46
【问题描述】:

如何将数据作为 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',

网格是空的。

【问题讨论】:

    标签: jquery hashmap jqgrid


    【解决方案1】:

    colModel 创建后无法更改。 一种可能的解决方案是拥有所有可能的列,然后按条件显示/隐藏某些列。

    您可以将服务器响应和网格配置放在这里以查看问题所在

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-06
      • 2019-04-16
      • 1970-01-01
      • 2021-04-02
      • 2023-03-07
      相关资源
      最近更新 更多