locked
Want to have a multi-line column on a web grid RRS feed

  • Question

  • User483055775 posted

    @grid.GetHtml(
    tableStyle: "grid",
    headerStyle: "head",
    alternatingRowStyle: "alt",
    columns: grid.Columns(
    grid.Column("Age"),
    grid.Column("Year"),
    grid.Column(columnName: "Notes", header: "Notes", format: @<text> @item.Notes </text>)));

    I want to insert a cr/lf into the item.Notes field - and that would make it break on that line - and continue printing on the next line, indented over to where

    that field starts on the page.

    The output I want is 

    Age  Year    Notes

     45   2016    This is the first line note for 2016

                       This is the second line note for 2016

                       This is the third line note for 2016

      46 2017     This is the first line note for 2017

                       

    Thanks very much for your attention.

    DonnieS

    Thursday, July 10, 2014 9:51 PM

Answers

  • User-821857111 posted

    If the notes are already separated by line breaks, you can use string.Replace to convert them to their HTML equivalent:

    @<text>@Html.Raw(item.Notes.ToString().Replace("\n", "<br />"))</text> 



    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, July 11, 2014 3:24 AM
  • User-821857111 posted

    Just add a style for the tr element

    tr{
        border-bottom: 1px dashed black;
    }
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, July 11, 2014 9:02 AM

All replies

  • User-821857111 posted

    If the notes are already separated by line breaks, you can use string.Replace to convert them to their HTML equivalent:

    @<text>@Html.Raw(item.Notes.ToString().Replace("\n", "<br />"))</text> 



    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, July 11, 2014 3:24 AM
  • User483055775 posted

    Thanks Mike,  as always, so very helpful and accurate.  Is there a way to put a line between each row - a separater.

    Don

    Age 45  Year 2014   Note for Year 1

                                  Note for Year 2

    -----------------------------------------------------------------------------------------------------------------

    Age 46 Year 2015  Note for Year 3

                                Note for Year 4

    -------------------------------------------------------------------------------------------------------------------

    Friday, July 11, 2014 8:33 AM
  • User-821857111 posted

    Just add a style for the tr element

    tr{
        border-bottom: 1px dashed black;
    }
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, July 11, 2014 9:02 AM
  • User483055775 posted

    Thanks - 

    Don

    Friday, July 11, 2014 9:54 AM