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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Change color of grid cell text when model changes

Thread ID:





132356 Aug 28,2017 01:51 PM UTC Aug 29,2017 10:55 AM UTC Xamarin.Forms 1
Tags: SfDataGrid
Asked On August 28, 2017 01:51 PM UTC

I have overridden OnInitializeDisplayView in my GridCellTextViewRenderer-derived class to change text color depending on a boolean in my model.

        public override void OnUpdateDisplayValue(DataColumnBase dataColumn, SfLabel view)
            base.OnInitializeDisplayView(dataColumn, view);
            if ((dataColumn.RowData as Player).InPlay == false)
                view.TextColor = Color.FromRgba(50, 50, 50, 50);

and added it to the grid like this

            sfGrid.CellRenderers.Add("TextView", new GridCellTextViewRendererExt());

This works find when the grid is first displayed, but if I change my underlying data model (in my case, after dragging a row to a new location) then my method above is not called, and the rows are drawn as default. How can I make this code called whenever the grid is drawn?

I've tried overriding OnUpdateDisplayValue

       public override void OnUpdateDisplayValue(DataColumnBase dataColumn, SfLabel view)
            base.OnUpdateDisplayValue(dataColumn, view);
            if ((dataColumn.RowData as Player).InPlay == false)
                view.TextColor = Color.FromRgba(50, 50, 50, 50);

but it is never called. Thanks.

Ashok N [Syncfusion]
Replied On August 29, 2017 10:55 AM UTC

Hi Tino, 
Thanks for contacting Syncfusion support. 
You can achieve your requirement by overriding OnUpdateCellStyle method in custom GridCellTextViewRenderer class, please refer the below code example. Also we have prepared the sample based on your requirement and attached in the below location for your reference, please refer it . 
protected override void OnUpdateCellStyle(DataColumnBase dataColumn) 
    // Enter Your code here   


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.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon 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.Close Icon