1

I want to display the document set properties in more user friendly way.

So I want to get e.G. this (Title, Description, Category, Company):

enter image description here

into a list inside the document set.

The purpose is, that I should be able to display the list in the document set with JavaScript in something like that:

enter image description here

Or is there a way to directly change to look and feel of those document set properties?

There will be about 20-25 properties in the set and if I show them all, well, it just doesn't look great and the user can not find anything.

I tried the script (added it into a script editor webpart) above the document set properties like this:

<script src="/_catalogs/masterpage/js/jquery-1.8.3.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
    // Get the document set's properties' parent div element
    var propsDiv = $("div[id='idDocSetPropertiesWebPart']");

    // Format the document set name
    propsDiv.find("h2").attr("style", "background: orange;");

    // Format the document set description
    propsDiv.find("div:first").attr("style", "background: green;");

    // Format the document set properties
    propsDiv.find("tr").each(function() {
        $(this).attr("style", "background: yellow;")
    });
})
</script>

That is my starting point, I will try to get my "look and feel" and post the script when I am done!

  • The error is quite clear, on line 614 you need to add a ) – Robert Lindgren Oct 19 '15 at 6:47
  • Damn mondays... Did that, but nothing changes in the properties. Ideas? – Patrick Oct 19 '15 at 7:12
  • Is this div even present on the page idDocSetPropertiesWebPart? I think you might have to substitute the id with the correct one from your page – Robert Lindgren Oct 19 '15 at 7:36
  • I hate mondays! Found the problem. Updated my question, When I am done completly, I'll post my answer! – Patrick Oct 19 '15 at 7:59
1

You could format the document set's properties with styles applied via javascript/jQuery. This is an example, customise to your requirement:

$(document).ready(function() {
    // Get the document set's properties' parent div element
    var propsDiv = $("div[id='idDocSetPropertiesWebPart']");

    // Format the document set name
    propsDiv.find("h2").attr("style", "background: orange;");

    // Format the document set description
    propsDiv.find("div:first").attr("style", "background: green;");

    // Format the document set properties
    propsDiv.find("tr").each(function() {
        $(this).attr("style", "background: yellow;")
    });
});

But if you're worried about all 25 of your properties showing in your document set home page, don't forget that you are able to choose which properties are actually displayed. You can do this from your library settings > click your document set under the "Content Types" heading > document set settings > welcome page columns.

  • thx, but I get an error. Updated my question. Any ideas? – Patrick Oct 19 '15 at 6:30
  • So did my script apply the formatting correctly on your page after you fixed the errors you were getting? As I say, you'll need to customise to your own requirement to make it look the way you want. – Submits Oct 19 '15 at 8:21
  • Hey Submits, yes it works perfectly! Do you have a idea how to get it into a collapsed list? Like in my picture in the question? – Patrick Oct 19 '15 at 8:30
  • 1
    You could build out your own table with each document set property as a row in the table. For each row you could attach a click handler which would collapse the row. Or you could try jQuery UI's accordian widget: jqueryui.com/accordion – Submits Oct 19 '15 at 8:35
0

Almost done. Only color and font stuff left.

Here my script:

<script src="/_catalogs/masterpage/js/jquery-1.8.3.min.js"></script>

    <script type="text/javascript">

    $(document).ready(function() {

        // Rest URL
        var requestUri = "/englishtest/_api/lists/getbytitle('Documents')/items";

            $.ajax({
                url: requestUri,
                type: "GET",
                headers: { "ACCEPT": "application/json;odata=verbose" },
                success: function (data) {

                    $.each(data.d.results, function (i, item){
                        var title = item.Title;
                        var description = item.DocumentSetDescription;
                        var company = item.Company;
                        var category = item.Category;


                        document.getElementById("head").innerHTML = title;  
                        document.getElementById("headcontent").innerHTML = "<table><tr><td>Description: </td><td>\u00A0 \u00A0" + description + "</td></tr></table>";                               
                        document.getElementById("companyContent").innerHTML = "<table><tr><td>" + company + "</td></tr></table>";
                        document.getElementById("categoryContent").innerHTML = "<table><tr><td>" + category + "</td></tr></table>";
                    })
                },
                error: function () {
                    alert("Error getting document set properties");
                }                     
            });                                       
    });

    </script>

<head>
  <meta charset="utf-8">
  <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
  <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
  <script>
    $(function() {
        $( "#accordion" ).accordion({
          heightStyle: "content"
        });
    });
  </script>
</head>
<body>

<div id="accordion">
  <h3 id="head"></h3>
  <div id="headcontent">
  </div>
  <h3>Company</h3>
  <div id="companyContent">
  </div>
  <h3>Category</h3>
  <div id="categoryContent">
  </div>
</div> 

</body>

And the output ist this:

enter image description here

Now I can display easily 25 document set properties and specify the element where I want to show it. I deleted the standard document set properties web part and added a script editor with the script above.

I know, it is not the nicest code but at least it works. Credit here to Submits!

If there are some "codegods", I appreciate any code improvments.

  • Thanks for coming back and sharing your solution with us. – Submits Nov 20 '15 at 10:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.