1

In a web application I am rendering a list of documents coming from a Sharepoint 2013 Document Library (the number of documents can vary, approximately, from 5 to 50). The user needs to be able to sort this documents from inside the application, and save the new order. Now, what is the best approach to achieve this?

So far, I have created a "Position" column in the document library that accepts integer numbers, and sort the documents by the value in that column (e.g., from 1 to 30). The problem is, when a user changes the position of a document in the application, I have to update the values of the "Position" column for all the other documents as well, so if document number 13 becomes number 16, all the documents from number 14 to the last needs to be updated.

Following this approach, I should ideally send x ajax post requests to the library like the following (I have stored in the application all the IDs for each document):

    $.ajax({
        url: url + "/Items(" + id + ")",
        type: "POST",
        data: data,
        headers: {
            Accept: "application/json;odata=verbose",
            "Content-Type": "application/json;odata=verbose",
            "X-RequestDigest": $("#__REQUESTDIGEST").val(),
            "IF-MATCH": "*",
            "X-Http-Method": "MERGE"
        }
    });

Is there an alternative to send so many ajax requests? Any other approach on how to handle this problem, by using only REST API?

  • If you just want to display this doc list in order, why not save "order" data in your web application? as you do not care how these docs are sorted in SP library. – Baker_Kong Apr 29 '20 at 06:06

0 Answers0