Search This Blog

Friday, May 27, 2016

Get All Of Specific Column in TD and TR Using Rest Api

</style>
<script type="text/javascript">

$(document).ready(function(){
   GetListItems();
});
function GetListItems()  
    var strHtml ="";
    var Increment=0;
    var tbl=$("#GetItems");
    var url = _spPageContextInfo.siteAbsoluteUrl + "/_api/web/lists/getbytitle('NGOPortals')/items"; 
    $.ajax 
    ({ 
        url: url, 
        type: "GET", 
        headers: 
        { 
            "Accept": "application/json;odata=verbose", 
            "Content-Type": "application/json;odata=verbose",
           
        }, 
        success: function(data)  
        { 
                strHtml +='<tr>';
            $.each(data.d.results, function(key, item) 
            {
                                if(Increment%6 == 0)
                                {
                                                                                strHtml +='<td>';
                                                                                                               
                                }
                                 strHtml +="<div><a href="+item.URL.Url.toString()+" target=\"_blank\">"+item.URL.Description.toString()+"</a></div>";
                                 Increment =Increment +1;
                                 
                if(Increment%6 == 0)
                                {
                                                                                strHtml +='</td>';                           
                                }

             
             
             
            });
             strHtml +='</tr>';
            $("#GetItems>tbody").html(strHtml);
             //var rowCount = $('#GetItems tr').length;
            // alert(rowCount); 
            $("#GetItems").show();
            
       
        }, 
        error: function(data)  
        { 
            //alert("Failed to get list items."); 
        } 
    }); 
  
}
</script>

No comments:

Post a Comment