aspxpivotgrid排序

protected virtual void SetSortBySummary()
        {
            foreach (PivotGridField field in grid.Fields)
            {
                if (field.Area == DevExpress.XtraPivotGrid.PivotArea.DataArea)
                {
                    field.CellStyle.Font.Bold = false;
                    field.HeaderStyle.Font.Bold = false;
                }
            }
            PivotGridField selectedField = grid.Fields[ddlSortByField.SelectedItem.Text];
            if (selectedField == null) return;
            selectedField.CellStyle.Font.Bold = true;
            selectedField.HeaderStyle.Font.Bold = true;

            //改变row的field之后改变sort的值
            try
            {
                sort = grid.GetFieldsByArea(DevExpress.XtraPivotGrid.PivotArea.RowArea)[0].ToString();
            }
            catch { }
            grid.Fields[sort].SortBySummaryInfo.FieldName = selectedField.FieldName;
            grid.Fields[sort].SortBySummaryInfo.SummaryType = selectedField.SummaryType;
           
        }

  

posted @ 2015-04-08 15:44  南修子  阅读(475)  评论(0编辑  收藏  举报