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.
Unfortunately, activation email could not send to your email. Please try again.

Customer formatting using QueryCellInfo

Thread ID:

Created:

Updated:

Platform:

Replies:

105586 Oct 15,2012 12:04 PM Nov 29,2012 02:28 AM WPF 1
loading
Tags: GridControl
John Millage
Asked On October 15, 2012 12:04 PM

I am using the DataGrid and trying to do some custom grid formatting using the QueryCellInfoCommand.  I get the style object out in the callback, but I need the object from the bound item source (because i determine the style from that).  How can i get this object using the cellStyle?  Thanks.

Ravi Shankar B [Syncfusion]
Replied On November 29, 2012 02:28 AM

Hi John,

 

We have analyzed your query and you can achieve your requirement by get the record through CellIdentity from GridDataStyleInfo as follows.

C# code snippet:

 void Model_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e)

        {

            var style = e.Style as GridDataStyleInfo;

            var cellidentity = style.CellIdentity;

            if (cellidentity != null && cellidentity.Record != null)

            {

                //Here based on the cellidentity.Record, you can apply style

 

                var Record = cellidentity.Record as DataRowView;

                var item =Record.Row.ItemArray[3];

                if (item.ToString().Contains("Mobile"))

                    e.Style.Background = Brushes.Lavender;

            }

        }

 

Alternatively, for your requirement we have Conditional Formatting feature, you can format the cell style by cell values as follows.

 

XAML code snippet:

 <syncfusion:GridDataControl.ConditionalFormats>
                <syncfusion:GridDataConditionalFormat Name="Column1" ApplyStyleToColumn="ProductPrice">
                    <syncfusion:GridDataConditionalFormat.Style>
                        <syncfusion:GridDataStyleInfo Background="BurlyWood" />
                    </syncfusion:GridDataConditionalFormat.Style>
                    <syncfusion:GridDataConditionalFormat.Conditions>
                        <syncfusion:GridDataCondition ColumnName="ProductPrice"
                                                      ConditionType="GreaterThan"
                                                      PredicateType="And"
                                                      Value="200" />
                    </syncfusion:GridDataConditionalFormat.Conditions>
                </syncfusion:GridDataConditionalFormat>
            </syncfusion:GridDataControl.ConditionalFormats>

 

 

We have created simple sample on this and you can download the sample from the following link.

http://www.syncfusion.com/downloads/Support/DirectTrac/101303/GDC_CustomFromatting-1610974018.zip

 

Regards,

Ravi Shankar B.


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;