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
914
How to: Show multiline cell data but trim each line of text
posted

I am porting from a C1 grid to this UltraGrid. One presentation I cannot seem to deal with is the following relating to the C1 grid's presentation of cell text:  A cell was able to have multiple lines of text where a string had embedded newlines (essentially making the text multiline). But each line of text was then trimmed to fit the column width. The autosize rows was able to revise the row height to fit the maximum height of a cell in that row.

With the UltraGrid, I can make the grid handle multiline cells and have the row height adapt, but all the text in a cell is shown - in some cases making the cell height way too big to be usable because I really do not want to see the entire text note. I do not want all the text to show, but only that which fits into the current column width. I've spent about a day looking over the past 30-days of messages here for some clue and the only thing I have seen that could come close is OwnerDraw - which I really did not want to get into. Does anyone have any ideas on how to accomplish what I need? What I predict as a workaround without owner draw, would be to dynamically modify a cell's text when a column was re-sized keeping each line of a multiline string trimmed according to the column width and whether a button was showing in the cell. This seems rather inefficient when an internal TextTrimming property could accomplish that. I could easily alter rowheight to accomodate the maximum number of text rows within a cell for any column across the grid as this data is fixed; the grid is used only to display data, not edit or enter new data. For what it is worth,the multiple lines of text within a cell represent that the cell actually contains more than one data object. The column represents a date, and the row represents a finding. But I do not want to have multiple rows for the same finding when there are two or more observations for the date. The C1 grid's text trimming was easily able to be used to deal with this presentation. How about the UltraGrid?

Parents
No Data
Reply
  • 12773
    posted

    Hello,

    I am not sure I followed the whole scenario you have describes, but you can resize the height of the row to match to the content, or set maximum “rows count” - RowSizingAutoMaxLines and hide the rest of the text.
    I think you can use the fallowing snipped in order to make your grid to wrap up the text in a column and allow the multiline:

        this.ultraGrid1.DisplayLayout.Override.RowSizingAutoMaxLines = 3;
        this.ultraGrid1.DisplayLayout.Bands[0].Columns[1].CellAppearance.TextTrimming = TextTrimming.EllipsisWord;
        this.ultraGrid1.DisplayLayout.Bands[0].Columns[1].CellMultiLine = DefaultableBoolean.True;
        this.ultraGrid1.DisplayLayout.Override.RowSizing = RowSizing.AutoFixed;

    If you wanted to resize each rwo any time its values were changed, as well as when first populated, you'd want to call " e.Row.PerformAutoSize();" in the InitializeRow event handler.

    I hope this helps.

    Sincerely,
    Dimi Gineva
    Developer Support Engineer
    Infragistics, Inc.

Children