This project has moved and is read-only. For the latest updates, please go here.

SPGetDisplayFromStatic All Columns

Nov 20, 2013 at 11:34 PM
Is there a way to get SPGetDisplayFromStatic to simply return all columns into the collection? E.g. if columnStaticNames is set a specific way, or another property? It would save me a lot of typing since I try to do all of my work using internals.

Thank you,
Nov 21, 2013 at 7:50 PM

You can pass in multiple column names in the columnStaticNames array. if that's not enough, you might just want to call GetList yourself and parse the column info out.

Nov 21, 2013 at 8:16 PM
Thanks. I'm passing more than 60 column names into there, and in a nutshell I need almost all of the fields on the form. I'll continue adding them to the array. I was just wanting to make sure I didn't miss something obvious.

If this gets too far out of control I'll call GetList to do it. :)

Nov 22, 2013 at 3:21 AM
Without knowing what you're doing exactly, it's hard to know what the best answer is, but if you've got 60 columns in play, why not just load all of the data into an array up front? If it's variable, then call GetList.

Dec 12, 2013 at 2:12 AM
Here's a utility function I wrote that I ended up using. Note that I'm filtering out some read only, static, and utility columns used by SharePoint (because I also use this for copying objects between lists), but that "filter" can easily be removed. Posting here in case others find it helpful.
* Gets all fields' static names from list
* @param {string} listName
* @param {string} [webURL]
* @returns {{}}
function GetAllListFieldStaticNames(listName, webURL){
    if(webURL == undefined || webURL.trim() == "") webURL = ""; // default to blank
    var fields = {};
        operation: "GetList",
        listName: listName,
        webURL: webURL,
        async: false,
        completefunc: function(xData, Status) {
            $(xData.responseXML).SPFilterNode("Field").each(function() {
                var node = $(this);
                if((node.attr("ReadOnly") != "TRUE" && node.attr("Hidden") != "TRUE"
                    && node.attr("StaticName") != "Attachments" && node.attr("StaticName") != undefined)
                    || node.attr("Name") == "ID"){
                    fields[node.attr("StaticName")] = node.attr("DisplayName");
    return fields;