Sharepoint 0365 List Views - Columns

Linda Mackintosh 6 Reputation points
2020-07-14T15:01:14.457+00:00

I have created a list for customers which contains a multiple line field which I have set a JSON code (shown below) in to ensure that the data is all seen as it is text wrapped however it only seems to work for single line fields and my field contains too much text for this. I have then created several views. The issue I have is that when moving back and forth to the views, the column for this text reduces automatically to around an inch in size. I can drag the column then save the view but if I go to another view and back then it reduces again. I am in a Modern view. How can I set the column width to prevent this or is there a JSON that will wrap the text but work for multiple lines ? I can add a width setting to the JSON but this then just prevents the column being made any bigger - the column still jumps to being smaller when you move to a different view. I am completely new to JSONs. Any advice welcome.

I have tried restarting the list and creating the views through List Settings as suggested in another forum but no joy.

Thank you

{
"$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
"elmType": "div",
"txtContent": "@currentField",
"style": {
"white-space": "normal",
"padding": "11px 0"
},
"attributes": {
"class": "ms-fontColor-themePrimary"
}
}

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
9,607 questions
{count} votes

5 answers

Sort by: Most helpful
  1. MichaelHan-MSFT 18,016 Reputation points
    2020-07-15T08:40:57.317+00:00

    After changing the column width by dragging it, you need to save the list view.

    Please notice the “View” pull down in the top right of the page. You should see that once you change a column width on the page a * appears after the “View” name.
    12551-1.png

    Select the “View” pull down there will be an option to Save view as. Save the “View”, using the same name as before, you are overviewing the old display with the new layout i.e. with different column widths.

    12464-2.png

    Below is my test result:

    12532-test.gif

    1 person found this answer helpful.

  2. matt howell 331 Reputation points
    2020-11-06T15:34:46.42+00:00

    Changing widths by dragging the column doesn't seem to be persistent even if you save the view. Most likely this isn't designed correctly by Msft. Try adding a min-width to your JSON style block:
    "min-width": "xxxpx"

    0 comments No comments

  3. Teresa Cyrus 51 Reputation points
    2021-01-26T22:14:30.697+00:00

    Great tip. Thanks.

    0 comments No comments

  4. Linda Mackintosh 6 Reputation points
    2021-01-27T08:15:33.423+00:00

    Thank you matthowell-6829 sorry very new to this coding. Do I just add your code before the last }} ? I tried this and it said invalid code. Thank you so much.

    0 comments No comments

  5. matt howell 331 Reputation points
    2021-01-27T13:16:53.053+00:00

    @Linda Mackintosh It has to go within the style block so here:
    {
    "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
    "elmType": "div",
    "txtContent": "@currentField",
    "style": {
    "white-space": "normal",
    "padding": "11px 0",
    "min-width": "xxxpx"
    },
    "attributes": {
    "class": "ms-fontColor-themePrimary"
    }
    }
    Or unencoded which is easier to understand
    {
    "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
    "elmType": "div",
    "txtContent": "@currentField",
    "style": {
    "white-space": "normal",
    "padding": "11px 0",
    "min-width": "xxxpx"
    },
    "attributes": {
    "class": "ms-fontColor-themePrimary"
    }
    }