I am getting the fields of a list view using the javascript object model


However, this does not return the fields in order which they are configured in the view. It just returns the schema xml with the internal names and we can read the field names using the "get_item()" method. I have observed that the order that is returned is the order in which the columns were created in the list.

Is there a way to read the current order of fields in list view using javascript object model ?

  • what are you trying to achieve with this information? maybe there is an other way to do what you want to do.
    – Gwny
    Jun 19, 2015 at 6:50
  • i have written a sharepoint hosted app where user selects list items and clicks custom ribbon action app. SP hosted app opens in modal dialog and displays the records in table which then can be printed. If the order of the columns is changed in the view, app does not present columns in that order. Jun 19, 2015 at 7:14
  • for me, the get_viewFields() method returns the order in which the fields appear in the view, not the order they were created as you said.
    – MdMazzotti
    Jun 19, 2015 at 7:57
  • did you change the order of the fields in the view after creating the columns ? Jun 19, 2015 at 8:20

1 Answer 1


You can give it a try using REST query as below:

<script src='http://code.jquery.com/jquery-1.11.3.min.js'></script>
var xmlString;
try {
        //REST Query to get the display form url 
            url: "http://<URL>/_api/Web/Lists(guid'<GUID>')/Views(guid'<GUID>')",
            type: "GET",
            async: false,
            headers: { "Accept": "application/json;odata=verbose" },
            success: function (data, textStatus, xhr) {
                           xmlString = data.d.ListViewXml;
            error: function (data, textStatus, xhr) {
                alert("Error while getting Display form url");
    catch (ex) {

var xmlDoc =$.parseXML(xmlString);
$xml = $(xmlDoc);
$viewFields = $xml.find("ViewFields");
if($viewFields[0].childNodes.length > 0){

    for(var i=0; i < $viewFields[0].childNodes.length; i++){

Hope this helps to resolve your query!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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