|
我写的合计,4.05下的
前台
<Columns>
<f:RowNumberField EnablePagingNumber="true" Width="30px" HeaderText="xh" />
<f:WindowField ColumnID="editField" TextAlign="Center" Icon="encil" ToolTip="编辑" WindowID="Window1" Title="编辑" DataIFrameUrlFields="ID"
DataIFrameUrlFormatString="~/Voucher/VouchEdit.aspx?id={0}" Width="30px"></f:WindowField>
<finkButtonField ColumnID="Delete" HeaderText=" " Width="30px" CommandName="Delete" ConfirmText="是否删除!" Icon="Delete"></finkButtonField>
</Columns>
</f:Grid>
<f:HiddenField runat="server" ID="hfGrid1Summary"></f:HiddenField>
后台
private void BindGrid(string strWhere)
{
Grid1.DataSource = null;
string sortField = Grid1.SortField;
string sortDirection = Grid1.SortDirection;
// 1.设置总项数
Grid1.RecordCount = _bll.GetRecordCount(strWhere);
// 2.获取当前分页数据
int rowbegin = Grid1.PageIndex * Grid1.PageSize;
int rowend = (Grid1.PageIndex + 1) * Grid1.PageSize;
DataTable table = _bll.GetListByPage(strWhere, sortField + " " + sortDirection, rowbegin, rowend).Tables[0];
//DataTable table = GetPagedDataTable(Grid1.PageIndex, Grid1.PageSize);
// 3.绑定到Grid
//DataTable table = GetDataTable();
DataView view1 = table.DefaultView;
view1.Sort = String.Format("{0} {1}", sortField, sortDirection);
Grid1.DataSource = view1;
Grid1.DataBind();
//显示页小计
OutputPageSummaryData(table);
//DataTable source = _bll.GetList(strWhere).Tables[0];
// strHtml = GridHelper.FormatAsHtml(Grid1, source);
}
private void OutputPageSummaryData(DataTable source)
{
double totalsl = 0.0f;
foreach (DataRow row in source.Rows)
{
object sl = row["SL"];
if (Convert.IsDBNull(row["SL"]))
{
sl = "0";
}
totalsl += Convert.ToDouble(sl);
}
JObject summary = new JObject();
summary.Add("Name", "页小计");
summary.Add("Major", totalsl.ToString("F2"));
summary.Add("SL", totalsl.ToString("F2"));
//hfGrid1Summary.Text = summary.ToString(Newtonsoft.Json.Formatting.None);
Grid1.SummaryData = summary;
} |
|