We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How to pass the current binded datagrid item to the converter when using a conditional formatting

Hi,

I'm analyzing your example named "Conditional Formatting Demo" in your online documentation on SfDatagrid control.
I'd like to implement a user interface where, for a particular column, the backgound color is changed according to some condition.
Your example is very good and uses a Converter that can calculate the correct background color related to the value of the associated cell but uses only the cell value without any parameter.
But, to decide witch color to return in my converter, I'd need not only the value of the cell but also other properties that belong to the current binded record of the currently displayed row.
So I need to pass an object parameter to that converter that should let me have access to the whole record binded to the row it is currently displayed.
How can I pass such a parameter to my converter?
Thank you.

Silvio

3 Replies

BR Balamurugan Rajaraman Syncfusion Team August 30, 2017 03:27 PM UTC

Hi Silvio, 
 
Thanks for contacting Syncfusion support. 
 
We have checked your query “How to pass additional parameter to the converter”. You can able to achieve your requirement using the MuliBinding concept by this way you can able to pass the additional parameter to the converter. Here we have passed the cell value and with additionally pass the collection of the particular row in to the converter as like the below code sample.  
 
<Window.Resources> 
        <local:ViewModel x:Key="viewmodel" /> 
        <local:CustomRowStyleMultiValueConverter x:Key="CustomRowStyleMultiValueConverter" /> 
        <Style x:Key="stylecolor" TargetType="Syncfusion:VirtualizingCellsControl"> 
            <Setter Property="Background"> 
                <Setter.Value> 
                    <MultiBinding Converter="{StaticResource CustomRowStyleMultiValueConverter}"> 
                        <Binding Path="IsChecked" /> 
                        <Binding RelativeSource="{RelativeSource Self}" /> 
                    </MultiBinding> 
                </Setter.Value> 
            </Setter> 
        </Style> 
    </Window.Resources> 

we have created sample as per the requirement and attached that sample for your reference. You can able to get it from the below link
 
 
 
Pease refer the below link for getting more information regarding this 
 
Regards, 
Balamurugan R 



SI Silvio August 30, 2017 04:54 PM UTC

Dear Balamurugan,


thank you very much for your very precious help!

MultiBinding was exactly what I needed.


Silvio Scattaglia



BR Balamurugan Rajaraman Syncfusion Team August 31, 2017 04:46 AM UTC

Hi Silvio, 
 
Thanks for the update, 
 
Please let us know if need any further assist on this. 
 
Regards, 
Balamurugan R 


Loader.
Up arrow icon