This is a migrated thread and some comments may be shown as answers.

Reg: Ignore casing while grouping the data

3 Answers 102 Views
PivotGrid
This is a migrated thread and some comments may be shown as answers.
Chakri
Top achievements
Rank 1
Chakri asked on 08 May 2019, 03:16 PM

Hi Team,

We are developed WPF application and used the telerik Rad PivotGrid to display and formats based on the needs. We have one issue upon groping the data on string columns. Our issue is if we group the data on string columns, it is considering the small letters and capital letters are treating it as different due to that values are totaling inaccurately. 

Following is the way we implemented to bind the data to grid.

1) We will prepare the query to fetch the data from DB based on the criteria selected by the user.

2) Data will be saved in VB.Net data table, from their we will bind it to pivot grid to do format the data as per customer needs.

3) In this case if we group the data on string columns, gird shows multiple rows based on data.

4) Suppose if we have column state, if it contains value as "CT" in one row and in another row if value is "ct", and if we group on state column. Grid shows two rows instead of one row.

5) We don't want to consider the casing(i.e case sensitive) of data in grid, please suggest us to implement the changes in application.

Thanks

Chakradhar

3 Answers, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 13 May 2019, 11:10 AM
Hello Chakradhar,

To achieve your requirement, you can implement a custom property group description and override the GroupNameFromItem virtual method where you can implement a custom logic that would equalize the different group names. For example:
public class CaseInsensitiveGroupDescription : PropertyGroupDescriptionBase
{
    protected override void CloneOverride(Cloneable source)
    {
    }
 
    protected override Cloneable CreateInstanceCore()
    {
        return new CaseInsensitiveGroupDescription();
    }
 
    protected override object GroupNameFromItem(object item, int level)
    {
        var baseValue = base.GroupNameFromItem(item, level);
 
        if (baseValue != null)
        {
            
            return ((string)baseValue).ToLower();
        }
        
    return null;
    }
}
Then you can apply it to the provider:
<pivot:LocalDataSourceProvider.RowGroupDescriptions>
    <local:CaseInsensitiveGroupDescription PropertyName="Product"/> 
</pivot:LocalDataSourceProvider.RowGroupDescriptions>

I hope that helps.

Regards,
Martin Ivanov
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
Chakri
Top achievements
Rank 1
answered on 14 May 2019, 02:04 PM

Hi Martin,

Thank you for quick reply, in the given code you have applied for one column that is "Product". But in our data table we have more than 50 string columns. And one more thing is we should to convert data into lower or upper. Our intention is to keep the data as it it and it should be case insensitive. 

In our application we are using the RadPivot grid as a user control so if we have common method it will be very useful for us. So please suggest is the best way to accomplish the requirement. 

Thank you.

Chakradhar

0
Martin Ivanov
Telerik team
answered on 17 May 2019, 10:31 AM
Hello Chakradhar,

If you want to apply the custom property group description for the scenario where the descriptions are added automatically you can use the PrepareDescriptionForField event of the data provider. This will allow you replace the description through the event arguments.

What casing it should be used is up to. Whatever works for you. Also, you don't need to restrict the naming to lowecase or uppercase only. You can modify the group name so it suits your needs. Additionally, the GroupNameFromItem method will replace only the name of the group but not the underlying item.

I hope this helps.

Regards,
Martin Ivanov
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.
Tags
PivotGrid
Asked by
Chakri
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Chakri
Top achievements
Rank 1
Share this question
or