Format a row when a bound field changes

7 posts, 0 answers
  1. Mark
    Mark avatar
    130 posts
    Member since:
    Oct 2014

    Posted 28 Jun 2018 Link to this post

    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

  2. Dimitar
    Admin
    Dimitar avatar
    2960 posts

    Posted 29 Jun 2018 Link to this post

    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.
  3. Mark
    Mark avatar
    130 posts
    Member since:
    Oct 2014

    Posted 02 Jul 2018 in reply to Dimitar Link to this post

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

     

    Thanks for the help.

  4. Mark
    Mark avatar
    130 posts
    Member since:
    Oct 2014

    Posted 02 Jul 2018 in reply to Mark Link to this post

    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?  

  5. Dimitar
    Admin
    Dimitar avatar
    2960 posts

    Posted 03 Jul 2018 Link to this post

    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.
  6. Mark
    Mark avatar
    130 posts
    Member since:
    Oct 2014

    Posted 03 Jul 2018 in reply to Dimitar Link to this post

    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.
  7. Dimitar
    Admin
    Dimitar avatar
    2960 posts

    Posted 04 Jul 2018 Link to this post

    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.
Back to Top