Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
685
Dynamic GroupBy Image
posted

I'm displaying a summary grid for an installer.  I need to alter the groupby col image dynamically.  I've messed with this quite a bit but I can't seem to make a dent.

The attached pic shows what I'm getting now, but I need the groupby header to show a check if they all pass, and an X if even one of them fails.

Parents
No Data
Reply
  • 1560
    Offline posted

    Hello,

    Thank you for the provided image.

    What I can suggest for achieving your requirement is using the InitializeGroupByRow event, which is fired for each group by row after the grid is initialized.

    All rows in a particular group can be retrieved in the event. A local Boolean variable, initially set to true, can be declared. Afterward, by looping through all rows for a particular group we can set the variable`s value based on whether there is a negative value in the record. If there is a false value we break the loop since the condition is to render the negative icon if at least one value is false. In case that all values are positive the variable`s value is set to true. As next step, the icon for this group by row is set based on the flag.

    I have created a small sample illustrating my suggestion. The Status column is boolean, however, the logic would be the same for values OK/Failed.

     private void ultraGrid1_InitializeGroupByRow(object sender, InitializeGroupByRowEventArgs e)
            {
                var grouped_rows = e.Row.Rows;
                bool flag = true;
                string parent = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName;
                foreach (var _row in grouped_rows)
                {
                    string value = _row.Cells[5].Value.ToString();
                    if (value == "False")
                    {
                        flag = false;
                        break;
                    }
                }
                if (flag)
                {
                    e.Row.Appearance.Image = new Bitmap(parent + "\\tick.webp");
                }
                else
                {
                    e.Row.Appearance.Image = new Bitmap(parent + "\\Warning.svg.png");
                }
            }

    Attached you will find my sample for your reference. Please test it on your side and let me know how it behaves. If this is not an accurate demonstration of what you are trying to achieve please feel free to modify it and send it back to me along with steps to reproduce. Alternatively, if the behavior cannot be replicated please feel free to provide your own sample. Remove any external dependencies and code that is not directly related to the issue, zip your application and attach it in this case.

    Having a working sample on my side, which I can debug, is going to be very helpful in finding the root cause of this behavior.

    Thank you for your cooperation.

    Looking forward to hearing from you.

    Sincerely,

    Teodosia Hristodorova

    Associate Software Developer

    0474.UltraGridGroupByRowImages.zip

Children