|
如题,示例中的效果我已经实现了,问题是再加一个GRID显示汇总行,复制了一份JS代码并修改,结果就是只有一个GRID显示汇总,如果注释掉其中一个,另一个是可以正常显示的,我对JS,CSS不太熟悉,难道还要再复制一份CSS修改?请大家帮忙看下,解决了的话请三石兄在示例中添加一下吧,多GRID汇总的例子,相信很多人会用到,谢谢了- private void OutputSummaryDataGrid1()
- {
- if (dtGrid1 != null && dtGrid1.Rows.Count > 0)
- {
- decimal donateTotal = 0;
- foreach (DataRow row in dtGrid1.Rows)
- {
- donateTotal += Math.Round(Convert.ToDecimal(row["fg_zongjin_e"]), 2);
- }
- JObject jo = new JObject();
- jo.Add("donateTotal", donateTotal);
- hfGrid1Summary.Text = jo.ToString(Newtonsoft.Json.Formatting.None);
- }
- else
- {
- hfGrid1Summary.Text = "0";
- }
- }
- private void OutputSummaryDataGrid2()
- {
- if (dtGrid2 != null && dtGrid2.Rows.Count > 0)
- {
- decimal donateTotal = 0;
- foreach (DataRow row in dtGrid2.Rows)
- {
- donateTotal += Math.Round(Convert.ToDecimal(row["rm_zongjin_e"]),2);
- }
- JObject jo = new JObject();
- jo.Add("donateTotalRM", donateTotal);
- hfGrid2Summary.Text = jo.ToString(Newtonsoft.Json.Formatting.None);
- }
- else
- {
- hfGrid2Summary.Text = "0";
- }
- }
复制代码
- <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="waihuishuju.aspx.cs" Inherits="EmptyProjectNet40.waihuishuju" %>
- <!DOCTYPE html>
- <html>
- <head runat="server">
- <title></title>
- <link href="~/css/main.css" rel="stylesheet" type="text/css" />
- <style type="text/css">
- .mygrid-row-summary.x-grid3-row
- {
- background-color: #efefef !important;
- background-image: none !important;
- border-color: #fff #ededed #ededed !important;
- visibility: hidden;
- }
- .mygrid-row-summary.x-grid3-row .x-grid3-td-numberer, .mygrid-row-summary.x-grid3-row .x-grid3-td-checker
- {
- background-image: none !important;
- }
- .mygrid-row-summary.x-grid3-row .x-grid3-td-numberer .x-grid3-col-numberer, .mygrid-row-summary.x-grid3-row .x-grid3-td-checker .x-grid3-col-checker
- {
- display: none;
- }
- .mygrid-row-summary.x-grid3-row td
- {
- font-size: 14px;
- line-height: 16px;
- font-weight: bold;
- color: red;
- }
- </style>
- </head>
- <body>
- <form id="form1" runat="server">
- <x:PageManager ID="PageManager1" AutoSizePanelID="Panel7" runat="server" />
- <x:Panel ID="Panel7" runat="server" EnableBackgroundColor="true" BodyPadding="3px"
- EnableLargeHeader="true" Title="Panel" ShowBorder="false" ShowHeader="True" Layout="VBox"
- BoxConfigAlign="Stretch">
- <Items>
- <x:Panel ID="Panel8" ShowBorder="True" ShowHeader="True" BoxFlex="1" Layout="Fit"
- runat="server" Title="RM进口数据">
- <x:Grid ID="Grid2" Title="RM进口数据" PageSize="80" ShowBorder="true" AllowPaging="true"
- ShowHeader="False" runat="server" EnableCheckBoxSelect="False" AutoHeight="true"
- DataKeyNames="Id" EnableRowNumber="True" IsDatabasePaging="true" OnPageIndexChange="Grid2_PageIndexChange"
- EnableMultiSelect="false" EnableRowSelectEvent="true" AllowSorting="true" SortColumnIndex="0"
- SortDirection="DESC" OnSort="Grid2_Sort">
- <Columns>
- <x:BoundField Width="20px" DataField="id" SortField="id" DataFormatString="{0}" HeaderText="id" Hidden="True" HideMode="Offsets" />
- <x:BoundField Width="150px" DataField="rm_ieguandanhao" ColumnID="rmieguandanhao" SortField="rm_ieguandanhao" DataFormatString="{0}" HeaderText="报关单号" />
- <x:BoundField Width="100px" DataField="rm_bizhi" SortField="rm_bizhi" DataFormatString="{0}" HeaderText="成交币种" />
- <x:BoundField Width="100px" DataField="rm_zongjin_e" ColumnID="rmzongjine" SortField="rm_zongjin_e" DataFormatString="{0}" HeaderText="成交总价($)" />
- </Columns>
- </x:Grid>
- <font color="#ff8c00"> <x:HiddenField runat="server" ID="hfGrid2Summary"> </x:HiddenField></font>
- </Items>
- </x:Panel>
- <x:Panel ID="Panel1" ShowBorder="True" ShowHeader="true" BoxFlex="1" Layout="Fit"
- runat="server" Title="FG出口数据">
- <Toolbars>
- <x:Toolbar ID="Toolbar1" runat="server">
- <x:Grid ID="Grid1" Title="FG出口数据" PageSize="80" ShowBorder="true" AllowPaging="true"
- ShowHeader="False" runat="server" EnableCheckBoxSelect="False" AutoHeight="true"
- DataKeyNames="Id" EnableRowNumber="True" IsDatabasePaging="true" OnPageIndexChange="Grid1_PageIndexChange"
- EnableMultiSelect="false" EnableRowSelectEvent="true" AllowSorting="true" SortColumnIndex="0"
- SortDirection="DESC" OnSort="Grid1_Sort">
- <Columns>
- <x:BoundField Width="150px" DataField="fg_ieguandanhao" ColumnID="fgieguandanhao" SortField="fg_ieguandanhao" DataFormatString="{0}" HeaderText="报关单号" />
- <x:BoundField Width="100px" DataField="fg_bizhi" SortField="fg_bizhi" DataFormatString="{0}" HeaderText="成交币种" />
- <x:BoundField Width="100px" DataField="fg_zongjin_e" ColumnID="fgzongjine" SortField="fg_zongjin_e" DataFormatString="{0}" HeaderText="成交总价($)" /
- </Columns>
- </x:Grid>
- <font color="#ff8c00"> <x:HiddenField runat="server" ID="hfGrid1Summary"> </x:HiddenField></font>
- </Items>
- </x:Panel>
- </Items>
- </x:Panel>
- </form>
- <script type="text/javascript">
- <font color="#0000ff"> var gridClientID = '<%= Grid1.ClientID %>';
- var gridSummaryID = '<%= hfGrid1Summary.ClientID %>';</font>
- function calcGridSummary(grid) {
- var donateTotal = 0, store = grid.getStore(), view = grid.getView(), storeCount = store.getCount();
- // 超出限制删掉了一部分
- // 页面第一个加载完毕后执行的函数
- function onReady() {
- var grid = X(gridClientID);
- grid.addListener('viewready', function () {
- calcGridSummary(grid);
- });
- // 防止选中合计行
- grid.getSelectionModel().addListener('beforerowselect', function (sm, rowIndex, keepExisting, record) {
- if (Ext.get(grid.getView().getRow(rowIndex)).hasClass('mygrid-row-summary')) {
- return false;
- }
- return true;
- });
- }
- // 页面AJAX回发后执行的函数
- function onAjaxReady() {
- var grid = X(gridClientID);
- calcGridSummary(grid);
- }
- </script>
- <script type="text/javascript">
- <font color="#0000ff"> var gridClientIDRM = '<%= Grid2.ClientID %>';
- var gridSummaryIDRM = '<%= hfGrid2Summary.ClientID %>';</font>
- function calcGridSummaryRM(grid) {
- var donateTotal = 0, store = grid.getStore(), view = grid.getView(), storeCount = store.getCount();
- // 超出限制,删掉了一部分
- // 向容器节点添加合计行的副本
- viewportNode.appendChild(clonesummaryNode);
- }
- // 页面第一个加载完毕后执行的函数
- function onReady() {
- <font color="#0000ff"> var gridRM = X(gridClientIDRM);
- gridRM.addListener('viewready', function () {
- calcGridSummaryRM(gridRM);</font>
- });
- // 防止选中合计行
- gridRM.getSelectionModel().addListener('beforerowselect', function (sm, rowIndex, keepExisting, record) {
- if (Ext.get(gridRM.getView().getRow(rowIndex)).hasClass('mygrid-row-summary')) {
- return false;
- }
- return true;
- });
- }
- // 页面AJAX回发后执行的函数
- function onAjaxReady() {
- <font color="#0000ff"> var gridRM = X(gridClientIDRM);
- calcGridSummaryRM(gridRM);</font>
- }
- </script>
- </body>
- </html>
复制代码
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
|