This is a migrated thread and some comments may be shown as answers.

Format a row when a bound field changes

6 Answers 57 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 2
Bronze
Iron
Veteran
Mark asked on 28 Jun 2018, 08:29 PM

I have a RadGridView that has data bound to it.  One of the fields is a bool field type.  What I want to happen, is if the user changes that value, I want the forecolor of the entire row to change.  So, in my RowFormatting, I have to code to change the forecolor, and this works, only after I move the record pointer or selected a different cell in the same row.  How can I get the row to change color as soon as I change the cell's value?

 

TIA

Mark

6 Answers, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 29 Jun 2018, 08:35 AM
Hi Mark,

This is because the value is changed after the cell is changed. You can set the EditMode of the checkbox column to fix this:
protected override void OnLoad(EventArgs e)
{
    base.OnLoad(e);
    var col = radGridView1.Columns[0] as GridViewCheckBoxColumn;
    col.EditMode = EditMode.OnValueChange;
}

I hope this will be useful. Let me know if you have additional questions.

Regards,
Dimitar
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Mark
Top achievements
Rank 2
Bronze
Iron
Veteran
answered on 02 Jul 2018, 02:07 PM

This was what I was exactly looking for, I just could not find it.

 

Thanks for the help.

0
Mark
Top achievements
Rank 2
Bronze
Iron
Veteran
answered on 02 Jul 2018, 03:36 PM

I do have one other question, I was trying to do this similarly to a GridViewTextBoxColumn, but I don't see editmode property there. What are the properties I would need to update to do the same for other editor control columns to do the same as the CheckBoxColumn?  

0
Dimitar
Telerik team
answered on 03 Jul 2018, 07:39 AM
Hello Mark,

There is no such property for the other editors. The checkbox is a permanent editor that is visible at all times, the other editors are only visible when the user is editing the cell. However, you can use ValueChanged event instead of CellValueChenged. This event will be fired after the value in the editor is changed. 

Should you have any other questions do not hesitate to ask.

Regards,
Dimitar
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Mark
Top achievements
Rank 2
Bronze
Iron
Veteran
answered on 03 Jul 2018, 11:54 AM
Well, this poses a problem then, as I am subscribing to the bound data's PropertyChanged event and not any event on the grid or its children.  Your proposal would have me subscribe to column's ValueChanged event for columns that I want to be Read/Write, which is inefficient, also would not work, as in the RowFormatting of the grid, I am looking again, at the bound data's values to determine if I am formatting the row or not, the Value of the cell doesn't affect the bound data until Validated.
0
Dimitar
Telerik team
answered on 04 Jul 2018, 05:47 AM
Hi Mark,

The data-bound value will be changed when the user leaves the cell and this will trigger the PropertyChanged event. There is no way to change it after each keystroke. What is the code that you are currently using to format the rows?

I have attached a small project that shows how you can use the ValueChanged event to format the row. I am using the Tag property to determine which row should be styled.

I am looking forward to your reply.

Regards,
Dimitar
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
GridView
Asked by
Mark
Top achievements
Rank 2
Bronze
Iron
Veteran
Answers by
Dimitar
Telerik team
Mark
Top achievements
Rank 2
Bronze
Iron
Veteran
Share this question
or