get a summery of for filtered items

4 posts, 1 answers
  1. MOhammad
    MOhammad avatar
    4 posts
    Member since:
    May 2014

    Posted 05 Nov 2018 Link to this post

    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 
  2. Answer
    Marin Bratanov
    Admin
    Marin Bratanov avatar
    4533 posts

    Posted 07 Nov 2018 Link to this post

    Hello Mohammad,

    The Count Aggregate will give you that information. You can see more about in the following resources:

    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.
  3. MOhammad
    MOhammad avatar
    4 posts
    Member since:
    May 2014

    Posted 08 Nov 2018 in reply to Marin Bratanov Link to this post

    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?

  4. Marin Bratanov
    Admin
    Marin Bratanov avatar
    4533 posts

    Posted 08 Nov 2018 Link to this post

    The built-in count should suffice.
    --Marin
Back to Top