is there any way to get a summery of for the count of records from radgrid after filtering.
see attached example for your reference.
thank you
see attached example for your reference.
thank you
3 Answers, 1 is accepted
0
Accepted
Hello Mohammad,
Regards,
Marin Bratanov
Progress Telerik
The Count Aggregate will give you that information. You can see more about in the following resources:
- demo (see the Product ID column, you can also remove the default grouping the demo has): https://demos.telerik.com/aspnet-ajax/grid/examples/functionality/grouping/group-footers/defaultcs.aspx.
- documentation on aggregates: https://docs.telerik.com/devtools/aspnet-ajax/controls/grid/how-to/Common/totals-in-grid-footers.
Here's also a very simple example I created for you:
<
telerik:RadGrid
runat
=
"server"
ID
=
"rg1"
OnNeedDataSource
=
"rg1_NeedDataSource"
AllowFilteringByColumn
=
"true"
ShowFooter
=
"true"
>
<
MasterTableView
>
<
Columns
>
<
telerik:GridBoundColumn
Aggregate
=
"Count"
FooterAggregateFormatString
=
"total count of items: {0}"
DataField
=
"Id"
></
telerik:GridBoundColumn
>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
and some dummy data to get it running:
protected
DataTable GetDummyData()
{
DataTable tbl =
new
DataTable();
tbl.Columns.Add(
new
DataColumn(
"Id"
,
typeof
(
decimal
)));
tbl.Columns.Add(
new
DataColumn(
"textField"
,
typeof
(
string
)));
tbl.Columns.Add(
new
DataColumn(
"valueField"
,
typeof
(
int
)));
tbl.Columns.Add(
new
DataColumn(
"fourthField"
,
typeof
(
string
)));
tbl.Rows.Add(
new
object
[] { 1,
"one"
, 1,
"red"
});
tbl.Rows.Add(
new
object
[] { 1,
"two"
, 2,
"green"
});
tbl.Rows.Add(
new
object
[] { 5,
"three"
, 3,
"blue"
});
tbl.Rows.Add(
new
object
[] { 6,
"four"
, 1,
"pink"
});
return
tbl;
}
protected
void
rg1_NeedDataSource(
object
sender, GridNeedDataSourceEventArgs e)
{
(sender
as
RadGrid).DataSource = GetDummyData();
}
Regards,
Marin Bratanov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
MOhammad
Top achievements
Rank 1
answered on 08 Nov 2018, 07:21 AM
thank you Marin,
an i use the Aggregate="Count" for specific value out of the box or i need to use the Aggregate="Custom" and write my own logic to count the different values?
0