Getting a count of non-null values in a DataTable attached to a LocalDataSourceProvider

4 posts, 1 answers
  1. Grinden
    Grinden avatar
    13 posts
    Member since:
    Jun 2013

    Posted 24 May Link to this post

    Hi,

    I have a LocalDataSourceProvider bound to a DataTable. Some of the columns allow nulls and some of the values in them are DBNull. I would like to be able to display a count of the values that aren't null. I've created my own aggregate function and I can add that to some of my AggregatePropertyDescriptions programmatically. I do have an example, but apparently I'm only allowed to upload images.

    The questions I've got are:

    Is there any easier way to do this?

    Can I make this aggregate function appear in the UI in the Field List, so users can select it?

    I only appear to be able to apply this to my nullable int property, and not my string property. Is that something I should be expecting?

    Many thanks,

    Richard

  2. Grinden
    Grinden avatar
    13 posts
    Member since:
    Jun 2013

    Posted 24 May in reply to Grinden Link to this post

    You can remove the .jpg extension to unzip it.
  3. Answer
    Polya
    Admin
    Polya avatar
    238 posts

    Posted 29 May Link to this post

    Hello Richard,

    With the R2 2016 release of UI for WPF the IgnoreNullValues property was introduced for the PropertyAggregateDescription. This property is of type bool and it is used to determine whether a specific PropertyAggregateDescription should ignore the null values when calculating its result. You can find more information about this property and how to use it in this help article: http://docs.telerik.com/devtools/wpf/controls/radpivotgrid/populating-with-data/data-localdatasource

    That said you can use the Count aggregate function for the PropertyAggregateDescription and set IgnoreNullValues=true to achieve the desired:

    DataTableDataProvider.AggregateDescriptions.Add(new PropertyAggregateDescription() { PropertyName = "Name", AggregateFunction = new CountAggregateFunction(), IgnoreNullValues = true });

    Hope this helps.

    Regards,
    Polya
    Progress Telerik
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
  4. Grinden
    Grinden avatar
    13 posts
    Member since:
    Jun 2013

    Posted 22 Jun in reply to Polya Link to this post

    Hi Polya,

    That's great, just what I needed.

    Thanks very much.

    Richard

Back to Top