Quantcast
Channel: Our ComponentOne » All Posts
Viewing all articles
Browse latest Browse all 14170

Reply To: How to show group row count?

$
0
0

Hi. Sorry for not getting back sooner. I think we are thinking of different things…

Let me try to explain again, and I’m adding a couple of screenshots to assist.

My problem is I allow grouping in my spread, which has a dynamic datasource. The user has 2 options, they can drag columns to the group bar at runtime *or* they can specify some columns in a metadata screen for the view so the spread will automatically group by those columns on page load.

My issue comes when 1.)the user selects the columns to group on the metadata screen(so no group events are hit, I automatically do the grouping on page load and 2.)more than 1 column is specified to be grouped by.

If they group dynamically in the spread or only 1 column for grouping is specified on the metadata screen, everything works fine. It is when they select multiple group columns and I try to do the grouping in page load, that the problem occurs.

The problem is this: In the following snippet below (modified slightly from what you provided to include a column header and total rows count), the first time I hit the code that checks for:

if (!(g.Rows[0] is FarPoint.Web.Spread.Model.Group))

The g.Rows[0] is a Group instance instead of an integer, so my logic is skipped and no column name is included and the totals are not printed. My group event executes the same code and when the 1st columns is grouped that way, that 'if’ succeeds sine g.Rows[0] is an int.

Screenshots attached show this. The 1st screenshot shows the 'if’ didn’t get executed – the column index is showing, not the text and no counts are displayed.

My question is what scenario would make g.Rows[0] be a Group instead of an int? Something is triggering this difference. Sorry that I don’t have a sample to reproduce. I’m working on it. But I wanted any suggestions you might have for what is causing this difference.

Thanks,
Mike

           gm = (FarPoint.Web.Spread.Model.GroupDataModel)spread.ActiveSheetView.DataModel;
            for (int i = 0; i < spread.ActiveSheetView.NonEmptyRowCount; i++)
            {
                if (gm.IsGroup(i))
                {
                    FarPoint.Web.Spread.Model.Group g;
                    g = gm.GetGroup(i);
                    g.Expanded = false;
                    total = 0;

                    total = g.Rows.Count;
                    column = g.Column;
                    if (!(g.Rows[0] is FarPoint.Web.Spread.Model.Group))
                    {
                        object o = gm.TargetModel.GetValue((int)g.Rows[0], column);                    
                        string s = o != null ? o.ToString() : String.Empty;

                        Object tagForColumn = spread.Columns[column].Tag;
                        var v = WorkingData.GetViewMetadataForGrid().Where(x => x.ColumnName == tagForColumn.ToString()).FirstOrDefault();
                        s = v.ColumnHeading + ":" + s;
                        g.Text = s + " (" + total.ToString() + ")";
                    }
                }

[/url]


Viewing all articles
Browse latest Browse all 14170

Trending Articles