BoldSignA modern eSignature application with affordable pricing. Sign up today for unlimited document usage!
Hello,
I have one Checkbox. If the checkbox is true
I want the text to be displayed as hexadecimal in the GridTextColumn, otherwise I want it to be displayed as decimal. For this, I wrote Converter as below.
class IntToHexadecimalConverter : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
if (values == null) return null;
if ((bool)values[1] == true)
return Int32.Parse(values[0].ToString().Replace("0x", ""), NumberStyles.HexNumber);
else return values[0];
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
It enforces UseBindingValue="true" when I implement it as below. Filtering page opening and filtering slows down if UseBindingValue is set to true. Also DataContenxt.IsHexadicamal comes as null. How can I solve these two problems?
<Syncfusion:GridTextColumn MappingName="ID"
Width="120"
UseBindingValue="True">
<Syncfusion:GridTextColumn.DisplayBinding>
<MultiBinding Converter="{StaticResource IntToHexadecimalConverter}">
<Binding Path="ID" />
<Binding Path="DataContext.IsHexadecimal" />
</MultiBinding>
</Syncfusion:GridTextColumn.DisplayBinding>
Özgür,
Currently, we are checking the reported issue with the provided details. We will check and update you with further details on April 27, 2023.
We appreciate your patience until then.
Regards,
Dhanasekar M.
Thanks, waiting for your reply Dhanasekar.
Özgür,
We have investigated the issue you reported with the details provided. Our analysis shows that the data context is not properly retrieved while performing multi-binding with the ViewModel property, leading to the reported issue.
To resolve this, we have prepared a sample for your scenario with the display binding converter alone. Please find the sample code below.
Xaml:
<syncfusion:GridTextColumn MappingName="OrderID" Width="120" UseBindingValue="True" DisplayBinding="{Binding Path=OrderID, Converter={StaticResource IntToHexadecimalConverter}, ConverterParameter={StaticResource viewModel}}" /> |
Converter:
class IntToHexadecimalConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value == null) return null;
var isHexaDecimal = (parameter as ViewModel).IsHexadecimal; if (isHexaDecimal == true)
return (Int32.Parse(value.ToString().Replace("0x", ""), NumberStyles.HexNumber)).ToString();
else return value.ToString(); }
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { throw new NotImplementedException(); } } |
C# code snippet to refresh the data grid while changing the check box state:
private void CheckBox_Click(object sender, RoutedEventArgs e) { // After changing the checkbox state refresh the view in SfDataGrid dataGrid.View.Refresh(); } |
Note:
We should refresh the view of the grid whenever the checkbox state changes in order to trigger the converter at runtime and update the UI accordingly.
Here, we have prepared the sample and video demo for your reference, please have a look at this.
If this post is helpful, please consider Accepting it as the solution so that other members can locate it more quickly.
As I mentioned in my first question, if I use UseBindingValue, there is a decrease in performance when opening the filtering page and applying the filtering. Isn't there a way to do this without using UserBindingValue?
Hi Özgür,
We are not able to replicate your reported performance issue while filtering and opening the FilterControl. Please refer our shared Video and demo in our previous update. Can you please provide the below details?
It will help us to proceed this issue further.