2

I have this code, where it should call the list item after the user has clicked on the list url.

$j('#cd-sp-lists li a').click(function(){       
    $j("#status").fadeIn('fast');       
    $j("#preloader").fadeIn('fast'); 
    $j('#page').empty();
    var ListGUID = $j(this).attr('title');                  
        $j().SPServices({
            operation: "GetListItems",
            async: false,
            listName: '' + ListGUID + '',
            CAMLViewFields: "<ViewFields><FieldRef Name='Title' /></ViewFields>",
            completefunc: function (xData, Status) {
              $j(xData.responseXML).SPFilterNode("z:row").each(function() {
                var liHtml = "<li>" + $j(this).attr("ows_Title") + "</li>";                 
                $j("#page").append(liHtml); 
                $j('#sp-lists').removeClass('is-visible');                  
                $j("#status").delay(1000).fadeOut(); 
                $j("#preloader").delay(1000).fadeOut("normal"); 
              });
            }
          });   
        return false;           
    }); 

Now this work fine. The problem is I dont want to add the fields name manualy to this script like this: var liHtml = "<li>" + $j(this).attr("ows_Title") + "</li>" it should get all item names ,value, and colum names based on that list.

Is there away to do that?

  • You could do a GetList call first, but at some point, you'd need to specify what field/value you want to write out. – Eric Alexander Apr 9 '15 at 13:39
1

In that case you should first get the list fields using below service call

$().SPServices({
    operation: "GetList",
    listName: '' + ListGUID + '',
    completefunc: function(xData, Status) { 
        //Extract field names
    },
    async: false
});

Inside completefunc you can have the actual call.

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.