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
925
Hide NullText for Template Add Row
posted

I have a grid where I've set the NullText to ***No Value Set*** and I also have a TemplateAddRow at the bottom, which I'd like to have a TemplateAddRowPrompt for. Unfortunately having both NullText and the Add Row Prompt doesn't seem to work very well as both lots of text are shown on top of each other!

Ideally I'd like to turn off the NullText for the Template Add Row, that way the prompt would be shown and the NullText would only start displaying once the user starts adding a row. Is this possible?

I'm using 2010 vol 1

Regards

Alex McMahon

Parents
  • 469350
    Verified Answer
    Offline posted

    Hi Alex,

    I played around with this a little, and the only way I could find to get it to work was to use a DrawFilter:


            public class MyDrawFilter : IUIElementDrawFilter
            {
                #region IUIElementDrawFilter Members

                bool IUIElementDrawFilter.DrawElement(DrawPhase drawPhase, ref UIElementDrawParams drawParams)
                {
                    // The only time we will ever get in there is for the BeforeDrawForeGround phase
                    // of an EditorWithTextDisplayTextUIElement in a TemplateAddRow where there is
                    // NullText applied.
                    return true;
                }

                DrawPhase IUIElementDrawFilter.GetPhasesToFilter(ref UIElementDrawParams drawParams)
                {
                    // Watch for an EditorWithTextDisplayTextUIElement
                    if (drawParams.Element is EditorWithTextDisplayTextUIElement)
                    {
                        // Get the cell.
                        UltraGridCell cell = drawParams.Element.GetContext(typeof(UltraGridCell)) as UltraGridCell;

                        // If the cell is not null, and it's in the TemplateAddRow, and there's
                        // a NullText applied to it, return the BeforeDrawForeGround phase.
                        if (cell != null
                            && !string.IsNullOrEmpty(cell.Column.NullText)
                            && cell.Row.IsTemplateAddRow
                            && (cell.Value is DBNull || cell.Value == null))
                        {
                            return DrawPhase.BeforeDrawForeground;
                        }
                    }

                    // Return None so the DrawFilter does nothing in any other case.
                    return DrawPhase.None;
                }

                #endregion
            }

Reply Children
No Data