I have a requirement where I have to dynamically push data. I have tried the same by using javascript array like this:
var dynamicData =[];
//Initializing dynamicData array through jstl
<c:forEach var="innerList" items="${mylist}">
<c:forEach var="obj" items="${innerList}">
dynamicData[i]="${obj.val}";
i++;
</c:forEach>
</c:forEach>
var dynamicData1 =[];
dynamicData1.push(dynamicData);
var $container = $("#spreadsheet");
var $console = $("#console");
var $parent = $container.parent();
$container.handsontable({
data: dynamicData1,
});
And its working
Now my problem is that I want to dynamically add few columns with type ‘autocomplete’.
For that, I guess i need to create a javascript object and do the same job as I have done with normal javascript array. The only difference is that this time I have to work with javascript object array.
So I have tried like this but its not working:
var dynamicData =[];
<c:forEach var="innerList" items="${mylist}">
<c:forEach var="obj" items="${innerList}">
var datacell = new Object();
datacell.type='autocomplete';
datacell.source= ["yellow", "red", "orange", "green", "blue", "gray", "black", "white"];
dynamicData.push(datacell);
</c:forEach>
</c:forEach>
var dynamicData1 =[];
dynamicData1.push(dynamicData);
Kindly help.