I have this grid that fills an array within an array. It creates according to one array and then fills that column with another array.
<div id="formula" data-bind="with:currentFormula">
<!-- ko foreach:$parent.tones-->
<div class="col-sm-2" data-bind="foreach:$parents[1].levels">
<a href="#" class="thumbnail img-responsive" data-bind="click: $root.hasCurrent() ? $root.currentFormula().setEnding.bind($index(),$parentContext.$index()) : $root.currentFormula().setStarting.bind($index(),$parentContext.$index())">
<img data-bind="attr:{ src: '/Content/images/colors/' + $index() + $parentContext.$index() + '.png' }" alt="" />
</a>
</div>
<!-- /ko-->
</div>
What I need to do is create a new column before col 1 and add the $index() + 1, or row number would work to that column.
I've looked all over and have not found anything that works.
How would I do this?
From what I can tell, your rows are being created based on
currentFormula.tones
within<!-- ko foreach:$parent.tones-->
and columns based ontones.levels
. So you should create adiv
that binds its text to$index() + 1
only if the firstlevel
(column). To do this, you will need to move your loop for creating columns up above thediv
that will represent the column.Something like this: