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

Reply To: C1DataGrid SummaryRow – skip rows

$
0
0

Hello Jason,

As such, you cannot skip some rows from the DataGrid Column before calculating the Sum for the respective grid Column. It includes every row within the Column.

Here is a workaround you may use to implement the same :
1) Lets say your DataGrid1 is bound to an Observablecollection of Type class Person >> person1.
2) Now create a second collection >> person2, consisting of those records which you want to include in the sum for the DataGrid1 Column 2.
3) Bind person2 to a DataGrid2 whose Visibility is set to "Collapsed".
4) Apply the sum aggregate on DataGrid2 Column2 from which you get the resquired result.
5) Add a BottomRow in DataGrid1 and assign the value calculated in Step4 to this rows Cell2.

        'Calculate the resultant from the DataGrid2
        'column2 >> "Age" Column
        Dim dac As New DataGridAggregatesCollection
        Dim dagsum As New DataGridAggregateSum
        dagsum.ResultTemplate = DataGridAggregateAvg.GetDataTemplateFromString("Sum Age : {0}")
        dac.Add(dagsum)
        DataGridAggregateSum.SetAggregateFunctions(datagrid2.Columns(col), dac)
        result = Convert.ToInt32(dac(0).GetResultText(datagrid2.Rows, datagrid2.Columns(2), False))

        'Add a Row in DataGrid1 and assign this value 
        'in its second cell
        Dim row As New C1.Silverlight.DataGrid.DataGridRow
        datagrid.Rows.BottomRows.Add(row)
        person.Add(New Person() With {.Name = "", .Address = "", .i = result})
        datagrid.DataContext = person

Refer to the attached sample implementing the same.

Hope it helps.

Regards,
Reema


Viewing all articles
Browse latest Browse all 14170

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>