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?
SIGN IN To post a reply.
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,
- Share us the Syncfusion NuGet version details.
- Is there an exception throws while filtering/grouping. If so, kindly share us the same.
- Share us the video demo showing the reported problem.
- Share us the complete grid code with your model class and datasource.
- 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!
- 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 (:
- The exception says that a bool can not be casted to a string.
- Uploaded small video - the "dm.Group" is Approved(=Angenommen), Approved is a property of Type bool.
- 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.
Video demo – https://www.syncfusion.com/downloads/support/directtrac/general/ze/GroupingInCA1355487367
We suggest you to share us the below details to proceed further,
- Share us the complete grid code with your model class and datasource.
- 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.
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
-
UN Unknown
- Sep 10, 2021 11:55 AM UTC
- Sep 15, 2021 12:01 PM UTC