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
close icon

Dynamically Highlight a specific row on a GridDataControl

When you click or select a record on a GridDataControl, that row becomes the active row and is highlighted.

I'm trying to utilize the event that highlights a row on the GridDataControl after selecting.

I ultimately want to dynamically choose which row I want highlighted based on a specific value, but I'm not sure what event does this.

Any help is appreciated, thanks!

3 Replies

AN Ashok N Syncfusion Team June 15, 2015 12:58 PM UTC

Hi Ari,

Thank you for contacting Syncfusion support.

We have analyzed your query and you can achieve your requirement by handling QueryCellInfo event, within this event you can set the Background for selected row by using GridDataControl.Model.Options.HighlightSelectionBackground property. For your refer we have attached the sample in the below sample link, please refer it.

public MainWindow()

{

    InitializeComponent();

    grid.Loaded += grid_Loaded;

}


void grid_Loaded(object sender, RoutedEventArgs e)

{

    this.grid.Model.QueryCellInfo += Model_QueryCellInfo;

}


void Model_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e)

{

    if (e.Style.RowIndex > 0)

    {

        var column = this.grid.VisibleColumns["EmployeeID"];

        int index = this.grid.VisibleColumns.IndexOf(column);

        var visiablecolumnindex= this.grid.Model.ResolveVisibleColumnIndexToPosition(index);

        var cell = this.grid.Model[e.Style.RowIndex, visiablecolumnindex].CellValue;

        var result = Convert.ToInt32(cell);

        if (result % 3 == 0)

        {

            this.grid.Model.Options.HighlightSelectionBackground = Brushes.Green;

        }

        else

            e.Style.Enabled = false;

    }

}

Sample link: http://www.syncfusion.com/downloads/support/forum/119383/ze/BackgroundColor1819005304

Please let us know if you require further assistance on this.

Thanks,

Ashok



AC Ari Case June 15, 2015 04:35 PM UTC

This helps but I'm trying to programmatically check for a specific value in a cell.

For example, as I loop through the grid, if column 3 equals "Hello" at row index 4, highlight that whole row.


AN Ashok N Syncfusion Team June 16, 2015 06:52 PM UTC

Hi Ari,

Thank you for update.

We have analyzed your query but we are unable to understand your requirement clearly. In our previous update itself we have highlight the whole row based on the cell value only. Could you please share more details regarding your requirement, that would be more helpful for further analyze.

Please let us know if you require further assistance.

Thanks,
Ashok



Loader.
Live Chat Icon For mobile
Up arrow icon