具有“本地"功能的jqGrid子网格.数据

编程入门 行业动态 更新时间:2024-10-18 20:20:47
本文介绍了具有“本地"功能的jqGrid子网格.数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试让我的子网格处理本地数据.但是,当我单击展开"时,我只会看到一个正在加载"框,就像网格试图从某处提取数据一样.我假设我不需要subGridUrl,因为主网格的数据类型是datatype:'local'.我还有什么需要做的吗?

I'm trying to get my subgrid to work with local data. However, when I click expand, I just get a Loading box like the grid is attempting to pull the data from somewhere. I'm assuming I don't need a subGridUrl since the master grid's datatype is datatype:'local'. Is there anything else I should be doing?

推荐答案

没有使用本地数据定义子网格的直接方法,但是您可以使用subGridRowExpanded(作为网格的子网格).一个人需要做的就是从内部结构中通过网格的rowid获取子网格的数据.例如,如果您将子栅格映射为

There are no direct way to define subgrid with local data, but you can relatively easy implement the same behavior using subGridRowExpanded (Subgrid as Grid). What one need to do is just to get from some you internal structures the data for the subgrid by the rowid of the grid. For example if you would have subgrids map as

var myGridData = [ // main grid data {id: "m1", col1: "11", col2: "12"}, {id: "m2", col1: "21", col2: "22"} ], mySubgrids = { m1: [ // data for subgrid for the id=m1 {id: "s1a", c1: "aa", c2: "ab", c3: "ac"}, {id: "s1b", c1: "ba", c2: "bb", c3: "bc"}, {id: "s1c", c1: "ca", c2: "cb", c3: "cc"} ], m2: [ // data for subgrid for the id=m2 {id: "s2a", c1: "xx", c2: "xy", c3: "xz"} ] };

在subGridRowExpanded内,您可以使用以下代码创建子网格:

Inside of subGridRowExpanded you can create subgrid with the following code:

$("#grid").jqGrid({ datatype: 'local', data: myGridData, colNames: ['Column 1', 'Column 2'], colModel: [ { name: 'col1', width: 200 }, { name: 'col2', width: 200 } ], ... subGrid: true, subGridRowExpanded: function (subgridDivId, rowId) { var subgridTableId = subgridDivId + "_t"; $("#" + subgridDivId).html("<table id='" + subgridTableId + "'></table>"); $("#" + subgridTableId).jqGrid({ datatype: 'local', data: mySubgrids[rowId], colNames: ['Col 1', 'Col 2', 'Col 3'], colModel: [ { name: 'c1', width: 100 }, { name: 'c2', width: 100 }, { name: 'c3', width: 100 } ], ... }); } });

演示实时显示结果:

更多推荐

具有“本地"功能的jqGrid子网格.数据

本文发布于:2023-11-11 05:54:37,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1577565.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:网格   功能   数据   quot   jqGrid

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!