2014-01-14 30 views

回答

0

我不確定要理解。你的意思是你想從Sharepoint列表中獲取數據,然後將它作爲HTML表格注入到你的頁面中? 如果是的話,使用SharepointPlus你可以這樣做:

$SP().list("Name of your list").get({fields:"Field1,Field2"}, function(data) { 
    // start building the code for your HTML table 
    var html = '<table><thead><tr><th>Column 1</th><th>column 2</th></tr></thead><tbody>'; 
    // build each row 
    for (var i=data.length; i--;) html += '<tr><td>'+data[i].getAttribute("Field1")+'</td><td>'+data[i].getAttribute("Field2")+'</td></tr>' 
    html += '</tbody></table>' 
    // now you can inject it somewhere into your page 
    $('body').append(html) 
})