Last active
January 4, 2018 12:35
-
-
Save mutuadavid93/dab86b20b2d2056c70ad991ec4434261 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
When looping Multiple items from a SharePoint List | |
and You want to render them on UI into individual rows | |
containing only a specific number of columns. :) | |
*/ | |
$(function() { | |
var $render = function (myarr){ | |
console.dir(myarr); // rendering logic. | |
}; | |
// Loop data.d.results Object from a SharePoint List. | |
var lsItems = [ | |
11, 21, 31, 41, 51, 61, 71, 81, | |
19, 13, 10, 20, 30, 40, 50, 60 | |
],$rowItems = []; | |
// 4 here is the Number of columns you want per row on your UI. | |
for(var $var = 0; $var < lsItems.length; $var++){ | |
if($var%4 === 0){ | |
var crtdArr = lsItems.slice($var, $var+4); | |
$rowItems.push(crtdArr); | |
} | |
} | |
$render($rowItems); // render on Browser. | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment