jqGrid 中的自定义客户端聚合
这个问题类似于自定义聚合/分组在jqGrid但有点不同。
我有以下 jqGrid.
它加载一次,我希望以下所有功能都在客户端完成。下拉菜单是一个选择器,可以更改数据的显示方式。举例来说,我想按州显示,它应该只显示州列(我可以通过显示和隐藏列来处理),并且我希望它聚合/求和“Number1”、“Number2”和还有“Number3”列。它应该看起来像这样(希望我的手动添加是正确的)。
我还需要能够返回到第一个网格,所以 869 需要重新退出将 Taylor Ridge、Skokie、Beecher 分为 285、489、95 值。这是 jqGrid 可以处理的事情吗?
以下是第一个网格的 XML,但我可以完全控制此 XML 的构建方式,因此我可以根据需要更改它。
<?xml version ='1.0' encoding='utf-8'?>
<result>
<row>
<cell>1</cell>
<cell>IL</cell>
<cell>SPARLAND</cell>
<cell>32</cell>
<cell>61</cell>
<cell>19</cell>
<cell>0</cell>
</row>
<row>
<cell>2</cell>
<cell>IL</cell>
<cell>EDWARDS</cell>
<cell>69</cell>
<cell>56</cell>
<cell>2</cell>
<cell>0</cell>
</row>
<row>
<cell>2</cell>
<cell>IL</cell>
<cell>SPARLAND</cell>
<cell>52</cell>
<cell>30</cell>
<cell>8</cell>
<cell>0</cell>
</row>
<row>
<cell>2</cell>
<cell>CA</cell>
<cell>TAYLOR RIDGE</cell>
<cell>285</cell>
<cell>72</cell>
<cell>15</cell>
<cell>0</cell>
</row>
<row>
<cell>1</cell>
<cell>CA</cell>
<cell>SKOKIE</cell>
<cell>489</cell>
<cell>60</cell>
<cell>12</cell>
<cell>0</cell>
</row>
<row>
<cell>1</cell>
<cell>CA</cell>
<cell>BEECHER</cell>
<cell>95</cell>
<cell>46</cell>
<cell>17</cell>
<cell>0</cell>
</row>
</result>
This question is similar to Custom aggregation/grouping in jqGrid but a little bit different.
I have the following jqGrid.
It is loaded once and I'd like all of the following functionality to be done client side. The drop down is a selector that changes how to display the data. Say for example I want to display by State, it should just show the State column (I can handle that through showing and hiding the columns), and I'd like it to aggregate/sum the "Number1", "Number2", and "Number3" columns as well. It should look something like this (Hopefully my manual addition is correct).
I'd also need to be able to GET BACK to the first grid though so, 869 needs to broken back out into 285, 489, 95 values for Taylor Ridge, Skokie, Beecher. Is this something that can be handled by jqGrid?
The following is the XML for the first grid, but I do have full control over how this XML is built so I can change that as necessary.
<?xml version ='1.0' encoding='utf-8'?>
<result>
<row>
<cell>1</cell>
<cell>IL</cell>
<cell>SPARLAND</cell>
<cell>32</cell>
<cell>61</cell>
<cell>19</cell>
<cell>0</cell>
</row>
<row>
<cell>2</cell>
<cell>IL</cell>
<cell>EDWARDS</cell>
<cell>69</cell>
<cell>56</cell>
<cell>2</cell>
<cell>0</cell>
</row>
<row>
<cell>2</cell>
<cell>IL</cell>
<cell>SPARLAND</cell>
<cell>52</cell>
<cell>30</cell>
<cell>8</cell>
<cell>0</cell>
</row>
<row>
<cell>2</cell>
<cell>CA</cell>
<cell>TAYLOR RIDGE</cell>
<cell>285</cell>
<cell>72</cell>
<cell>15</cell>
<cell>0</cell>
</row>
<row>
<cell>1</cell>
<cell>CA</cell>
<cell>SKOKIE</cell>
<cell>489</cell>
<cell>60</cell>
<cell>12</cell>
<cell>0</cell>
</row>
<row>
<cell>1</cell>
<cell>CA</cell>
<cell>BEECHER</cell>
<cell>95</cell>
<cell>46</cell>
<cell>17</cell>
<cell>0</cell>
</row>
</result>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我觉得你的问题很有趣。此外,因为你几乎花费了所有的声誉点来获得赏金,所以我认为你确实需要解决问题。所以我为您制作了以下演示。一开始,它显示完整的网格而不进行分组:
对于选择元素,您可以选择分组列并接收结果,如
或
取决于选择元素中的选择。如果您选择“无分组”,网格的原始视图将被恢复。
对于实现,我使用了
groupSummary
以及 摘要类型。我建议您另外阅读答案,其中描述了如何自定义分组的摘要行。
demo正文的HTML代码是
对应的JavaScript代码如下:
I find your question interesting. Moreover because you spend almost all your reputation points for the bounty I decided that you really need the solution of the problem. So I made the following demo for you. At the start it displays the full grid without grouping:
With respect of the select element you can choose the grouping column and receive as the result like
or
depend on the choice in the select element. If you choose "No grouping" the original view of the grid will be restored.
For the implementation I used
groupSummary
with the custom implementation of summaryType.I recommend you to read the answer additionally which describes how one can customize the summary row of the grouping.
The HTML code of body of the demo is
The corresponding the JavaScript code is below: