Loading...

RE: Web Part to display a list across columns

RE: Web Part to display a list across columns

#7156
Anonymous
Anonymous
Participant

Hi,

I’ve tried out the same thing using jQuery but it didn’t help out.

My list has below items:

Item1
Item2
Item3
Item4
Item5
Item6
Item7
Item8
Item9
Item10

Its displaying the result like this:
Item1          Item2          Item3          Item4          Item5

The order is correct. But its not displaying the rest of the items in next row. Please check the code below and suggest:

<script type='text/javascript'> var index = 0; var rowmax = 8;</script>
<script language="javascript" type="text/javascript">
var title = "";
var url = "";
$(document).ready(function () {
GetData();
//alert($('#tabk').find('td[colspan!=""]').length);
});
function GetData() {
$().SPServices({
operation: "GetListItems",
async: false,
listName: "TestFooter",
CAMLViewFields: "<ViewFields><FieldRef Name='Title' /><FieldRef Name='Link' /></ViewFields>",
completefunc: function (xData, Status) {
$(xData.responseXML).SPFilterNode("z:row").each(function () {
AddRowToTable(title, url);
title = $(this).attr("ows_Title");
url = $(this).attr("ows_Link");
// alert(title);
//AddRowToTable(title, url);
});
}
});
}
function AddRowToTable(title, url) {
if (index == 0) {
index++;
$("#abk").append("<tr>");
} else if (index <= 5) {
$("#tabk").append("<td><a href=" + url + ">" + title + "</a></td>");
index++;
} else {
index = 0;
$("#tabk").append("</tr>");
}
}
</script>
<div id="siteOwner">
<table id="tabk">
</table>
</div>