Sunday 22 August 2021

SharePoint Online : Comments on List Formatting JSON

 SharePoint Online : Show comments on List Formatting JSON. 

Following source code will display List item comments count and button to open comments with edit item. 




Click on comments button will following screen to add and delete comments. 






Source Code : 


{

  "$schema": "https://developer.microsoft.com/json-schemas/sp/view-formatting.schema.json",

  "hideSelection": true,

  "hideColumnHeader": true,

  "rowFormatter": {

"elmType": "div",

"style": {

  "display": "flex",

  "flex-direction": "row",

  "height": "50px",

  "width": "285px"

},

"children": [

  {

"elmType": "div",

"style": {

  "display": "flex",

  "flex-direction": "column",

  "align-items": "center",

  "justify-content": "center",

  "height": "100%",

  "width": "15%"

},

"children": [

  {

"elmType": "div",

"style": {

  "border-width": "2px",

  "border-style": "solid",

  "height": "60px"

},

"attributes": {

  "class": "ms-borderColor-neutralSecondary"

}

  },

  {

"elmType": "div",

"style": {

  "height": "60px",

  "width": "20px",

  "border-radius": "50%",

  "cursor": "pointer",

  "outline": "none",

  "background-color": "black"

},

"attributes": {

  "class": "ms-bgColor-themePrimary"

}

  },

  {

"elmType": "div",

"style": {

  "border-width": "2px",

  "border-style": "solid",

  "height": "60px"

},

"attributes": {

  "class": "ms-borderColor-neutralSecondary"

}

  }

]

  },

  {

"elmType": "div",

"style": {

  "font-size": "20px",

  "width": "50%",

  "text-align": "left",

  "cursor": "pointer",

  "color": "#34A4E3"

},

"txtContent": "[$Title]",

"customCardProps": {

  "directionalHint": "rightCenter",

  "isBeakVisible": true,

  "openOnEvent": "click",

  "formatter": {

"elmType": "div",

"style": {

  "display": "flex",

  "flex-direction": "column",

  "height": "700px",

  "width": "850px",

  "position": "static",

  "top": "auto"

},

"children": [

  {

"elmType": "div",

"txtContent": "[$Title]",

"style": {

  "height": "50px",

  "width": "100%",

  "color": "white",

  "font-size": "20px",

  "display": "flex",

  "align-items": "center",

  "padding-left": "40px",

  "background-color": "#34A4E3"

},

"attributes": {

  "class": "ms-bgColor-themePrimary"

}

  },

  {

"elmType": "a",

"attributes": {

  "href": "[$pict]",

  "target": "_blank"

},

"children": [

  {

"elmType": "img",

"style": {

  "height": "95%",

  "width": "95%",

  "margin-top": "10px"

},

"attributes": {

  "src": "[$pict]",

  "title": "[$Title]"

}

  }

]

  },

  {

    "elmType": "button",  

  "customRowAction": {  

    "action": "defaultClick"  

  },  

  "attributes": {  

    "class": "ms-fontColor-themePrimary ms-fontColor-themeDark--hover",  

    "title": "Open Comment"  

  },  

  "style": {  

    "border": "none",  

    "background-color": "transparent",  

    "cursor": "pointer"  

  },  

  "children": [  

    {  

      "elmType": "span",  

      "attributes": {  

        "iconName": "OpenPane",  

        "class": "ms-font-xxl"  

      }  

    }  ,

{

  "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",

  "elmType": "div",

 "style": {    "float": "left",

    "padding": "10px"

},

  "attributes": {

    "class": "ms-fontColor-themePrimary ms-fontSize-m"

  },

  "children": [

    {

      "elmType": "span",

      "style": {

        "padding-right": "10px",

"float": "left"

      },

      "attributes": {

        "iconName": "Comment"

      }

    },

    {

      "elmType": "span",

      "txtContent": "=if([$_CommentCount] == '' , 0 ,[$_CommentCount]) "

    }

  ]

}  

  ]},

  {

"elmType": "div",

"txtContent": "[$Description]",

"style": {

  "height": "80%",

  "width": "85%",

  "padding-top": "20px"

}

  }



  


]

  


  }

}

  }

]

  }

}

SharePoint Office 365 List Tile View

SharePoint Office 365 List formatting with Tile view 


Products can be shown in following nice way. 







Step 1: Create List with following 4 columns 

Title : Single Line Text
Location: Single Line Text
ProductPhoto : HyperLink 
ProjectURL : HyperLink ,


Step 2 : Upload Proper data 

Step 3 :  GO to All Items in List and click on Format current view as shown in following 





Step 4:  select Advance mode  as shown in following picture 




Step 5:  Copy following code in Text Editor and save it. 





Step 6:  Select Tile and save as view as showing in following picture. 








Source Code : 


{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/tile-formatting.schema.json",
"height": "450",
"width": "300",
"formatter": {
"elmType": "div",
"style": {
"display": "flex",
"align-items": "stretch",
"margin-bottom": "16px",
"min-width": "150px",
"flex-grow": "1",
"justify-content": "space-around",
"padding": "8px",
"color": "#333333"
},
"children": [
{
"elmType": "div",
"style": {
"width": "95%",
"height": "98%",
"box-shadow": "0px 1.6px 3.6px 0 #00000024, 0px 0.3px 0.9px 0 #00000024",
"overflow": "hidden",
"border-radius": "2px"
},
"attributes": {
"class": "ms-bgColor-neutralLighterAlt"
},
"children": [
{
"elmType": "div",
"style": {
"display": "inline-block",
"min-width": "250px",
"text-align": "center",
"margin-top": "50px"
},
"children": [
{
"elmType": "img",
"attributes": {
"src": "=if([$ProductPhoto] == '', @currentWeb + '/_layouts/15/userphoto.aspx?size=M', [$ProductPhoto])",
"title": "=if([$ProductPhoto] == '', 'No picture available', [$Picture.desc])"
},
"style": {
"width": "85%",
"height": "200px"
}
}
]
},
{
"elmType": "div",
"style": {
"display": "inline-block",
"min-width": "250px",
"vertical-align": "top",
"padding-top": "16px",
"text-align": "center"
},
"children": [
{
"elmType": "div",
"style": {
"margin-bottom": "15px",
"font-size": "20px",
"font-weight": "600"
},
"txtContent": "[$Title]"
},
{
"elmType": "div",
"style": {
"font-size": "14px",
"margin-bottom": "20px",
"text-align": "center"
},
"txtContent": {
"operator": "+",
"operands": [
"",
"[$Location]"
]
}
},
{
"elmType": "a",
"style": {
"text-decoration": "none"
},
"attributes": {
"href": "[$ProjectURL]",
"target": "_blank"
},
"children": [
{
"elmType": "div",
"style": {
"font-size": "14px",
"margin-top": "15px",
"height": "30px",
"text-align": "center",
"width": "144px",
"vertical-align": "middle",
"display": "inline-block",
"color": "#444",
"border": "2px solid #CCC",
"background": "#DDD",
"box-shadow": "0 0 5px -1px rgba(0,0,0,0.2)",
"cursor": "pointer",
"max-width": "100px",
"padding": "6px 10px 0px 10px"
},
"attributes": {
"target": "_blank",
"class": "ms-bgColor-white--hover"
},
"txtContent": "View Project"
}
]
}
]
}
]
}
]
}
}



Output 





SharePoint Office 365 List formatting with Tile view

SharePoint Office 365 List formatting with Tile view 

Products can be shown in following nice way. 





Step 1: Create List with following 4 columns 

Title : Singe Line Text
Location: Singe Line Text
ProductPhoto : HyperLink ,
Features: Multilines Lines Text

Step 2 : Upload Proper data 

Step 3 :  GO to All Items in List and click on Format current view as shown in following 





Step 4:  select Advance mode  as shown in following picture 




Step 5:  Copy following code in Text Editor and save it. 





Step 6:  Select Tile and save as view as showing in following picture. 








Source Code


{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/view-formatting.schema.json",
  "tileProps": {
    "height": "450",
    "width": "300",
    "formatter": {
      "elmType": "div",
      "style": {
        "display": "flex",
        "align-items": "stretch",
        "margin-bottom": "16px",
        "min-width": "150px",
        "flex-grow": "1",
        "justify-content": "space-around",
        "padding": "8px",
        "color": "#333333"
      },
      "children": [
        {
          "elmType": "div",
          "style": {
            "width": "95%",
            "height": "98%",
            "box-shadow": "0px 1.6px 3.6px 0 #00000024, 0px 0.3px 0.9px 0 #00000024",
            "overflow": "hidden",
            "border-radius": "2px"
          },
          "attributes": {
            "class": "ms-bgColor-neutralLighterAlt"
          },
          "children": [
            {
              "elmType": "div",
              "style": {
                "display": "inline-block",
                "min-width": "300px"
              },
              "children": [
                {
                  "elmType": "img",
                  "attributes": {
                    "src": "=if([$ProductPhoto] == '', @currentWeb + '/_layouts/15/userphoto.aspx?size=M', [$ProductPhoto])",
                    "title": "=if([$ProductPhoto] == '', 'No picture available', [$Picture.desc])"
                  },
                  "style": {
                    "width": "100%",
                    "height": "200px"
                  }
                }
              ]
            },
            {
              "elmType": "div",
              "style": {
                "display": "inline-block",
                "min-width": "300px",
                "vertical-align": "top",
                "padding-left": "16px",
                "padding-top": "16px"
              },
              "children": [
                
                {
                  "elmType": "div",
                  "style": {
                    "margin-bottom": "12px",
                    "font-size": "16px",
                    "font-weight": "600"
                  },
                  "txtContent": "[$Title]"
                },
                {
                  "elmType": "div",
                  "txtContent": "Location",
                  "style": {
                    "color": "#767676",
                    "font-size": "12px",
                    "margin-bottom": "2px"
                  }
                },
                {
                  "elmType": "div",
                  "style": {
                    "font-size": "14px",
                    "margin-bottom": "12px"
                  },
                  "txtContent": {
                    "operator": "+",
                    "operands": [
                     
                      "",
                      "[$Location]"
                    ]
                  }
                },
                {
                  "elmType": "div",
                  "txtContent": "Features",
                  "style": {
                    "color": "#767676",
                    "font-size": "12px",
                    "margin-bottom": "2px"
                  }
                },
                {
                  "elmType": "div",
                  "style": {
                    "font-size": "14px",
                    "margin-bottom": "10px",
                    "width": "235px",
                    "height": "70px"
                  },
                  "txtContent": "[$Features]"
                }
              ]
            }
          ]
        }
      ]
    }
  }
}



Output