Can not filter grid by a column of type boolean

Hey guys!

We have a grid with a custom column of type boolean. We used a colum template with a checkbox for this and everything works fine, we also can call Sort() this column.
But we are not able to group the column. This is because of the GetFormattedValue method in the DataUti class does this:

public static string GetFormattedValue(object value, string format)
{
List<string> source = new List<string>()
{
"Double",
"Int64",
"Int32",
"Int16",
"Decimal",
"Single"
};
if (value?.GetType().Name == "DateTime" || value?.GetType().Name == "DateTimeOffset")
return Intl.GetDateFormat<object>(value, format);
return value != null && source.Any<string>((Func<string, bool>) (t => value.GetType().Name.Contains(t))) ? Intl.GetNumericFormat<object>(value, format) : (string) value;
}


If value is a boolean, the code tries to call e.g "(string) true" which is not possible. "true.ToString()" would be working.

Is there an other way to group by boolean columns in a SfGrid? 


3 Replies

JP Jeevakanth Palaniappan Syncfusion Team September 13, 2021 08:02 AM UTC

Hi Patrick, 

Greetings from Syncfusion support. 

We have validated your query by preparing a sample based on your scenario but unfortunately we are unable to reproduce the reported problem from our end. We are able to do filtering and grouping action in the Boolean type column. Please refer the below validated sample for your reference. 


If you are still facing any issues then kindly share us the below details, 

  1. Share us the Syncfusion NuGet version details.
  2. Is there an exception throws while filtering/grouping. If so, kindly share us the same.
  3. Share us the video demo showing the reported problem.
  4. Share us the complete grid code with your model class and datasource.
  5. Kindly share us the issue reproducing sample or reproduce the issue in the above provided sample.

The above requested details will be helpful for us to validate your query and to provide you with a better solution as early as possible. 

Regards, 
Jeevakanth SP. 



UN Unknown September 14, 2021 07:23 AM UTC

Hey, thanks for the response!


  1. We are running 19.1.0.54 - not the latest version but we can not update the next 1-2 weeks. If it is solved in one of those we just have to wait a bit (: 
  2. The exception says that a bool can not be casted to a string.
  3. Uploaded small video - the "dm.Group" is Approved(=Angenommen), Approved is a property of Type bool.
  4. Can't show so much and have no time for a reproduction right now, maybe the new information is enough? If not I will try to take some time. We Use a custom adaptor (the grouping is seen in the video) - the Approved field   is a custom template. 

Thanks for taking the time.
Best regards



Attachment: GroupingIssue_928c0e00.zip


JP Jeevakanth Palaniappan Syncfusion Team September 15, 2021 12:01 PM UTC

Hi Patrick, 

Based on the shared details, we have created a sample(version – 19.1.0.54) with custom adaptor and tried grouping a bool Type column which is also having SfCheckBox in the Column template. But we are unable to reproduce the reported problem. We have attached the validated sample and video demo below for your reference. 



We suggest you to share us the below details to proceed further, 

  1. Share us the complete grid code with your model class and datasource.
  2. Kindly share us the issue reproducing sample or reproduce the issue in the above provided sample.

The above requested details will be helpful for us to validate your query and to provide you with a better solution as early as possible. 

Regards, 
Jeevakanth SP. 


Loader.
Up arrow icon