Note that there are some explanatory texts on larger screens.

plurals
  1. POIterate through indexes of array using knockout
    primarykey
    data
    text
    <p>Is there a way to loop through a knockout observableArray's indexes, much like you would with a for loop in a language like C# or Java?</p> <p>With the code below, I'm just grabbing from the first index ( 0 ) but I want to be able to loop through the indexes and get the values from them as they come</p> <pre><code>&lt;table class="table table-hover table-bordered table-condensed"&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt; &lt;input type="checkbox" data-bind="checked: SelectAll" value="0" /&gt; &lt;/th&gt; &lt;th&gt;Employee Name&lt;/th&gt; &lt;th&gt;Sun&lt;/th&gt; &lt;th&gt;Mon&lt;/th&gt; &lt;th&gt;Tue&lt;/th&gt; &lt;th&gt;Wed&lt;/th&gt; &lt;th&gt;Thu&lt;/th&gt; &lt;th&gt;Fri&lt;/th&gt; &lt;th&gt;Sat&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody data-bind="foreach: Items"&gt; &lt;tr&gt; &lt;td&gt; &lt;input type="checkbox" class="entity-id" data-bind="if: Timesheets()[0].RowID == 0, checked: IsChecked" /&gt; &lt;/td&gt; &lt;td&gt;&lt;a class="span8" data-bind="if: Timesheets()[0].RowID == 0, text: EmployeeName, attr: { rowspan: Timesheets()[0].RowSpan }"&gt;&lt;/a&gt; &lt;/td&gt; &lt;td&gt;&lt;input type="text" class="span6" data-bind="value: Timesheets()[0].SundayHours"/&gt; &lt;/td&gt; &lt;td&gt;&lt;input type="text" class="span6" data-bind="value: Timesheets()[0].MondayHours" /&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" class="span6" data-bind="value: Timesheets()[0].TuesdayHours"/&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" class="span6" data-bind="value: Timesheets()[0].WednesdayHours"/&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" class="span6" data-bind="value: Timesheets()[0].ThursdayHours"/&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" class="span6" data-bind="value: Timesheets()[0].FridayHours"/&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" class="span6" data-bind="value: Timesheets()[0].SaturdayHours"/&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; </code></pre> <p>Is there a way to do this with knockout?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload