I am trying to build up a list of cell data for a column (which could any one of seven columns), in a jQuery created table. I am able to get an individual cell with the code below. The data returned is either a zero or a one (0 or 1), dependent on the background color of the cell (which can be blue or red).
In the code below, for example cell 0,3 (the first cell in column 3) which has a red background color, would return:
Cell Data At [0,3] : 1
I wish to do this for every cell in a column, (which has 29 rows). For example, in column 3 (the fourth column): 0,3 1,3 2,3 4,3... to 28,3
It would need to return, for example:
Data At Column 3 : 0,0,0,1,0,0,0,0,0,1,0,0,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1
I guess I need to build a for loop but I am at a loss of where to even begin.
The button:
<input type="text" placeholder="0,0" id="J_cellIndex" value="0,0"/> <button class="J_sheetControl" id="J_timingGetCell">GetCell</button>
The script on html page:
$("#J_timingGetCell").click(function(ev){
var cellIndex = $("#J_cellIndex").val().split(',');
var cellData = sheet.getCellState(cellIndex);
var $dataDisplay = $("#J_dataDisplay") ;
$dataDisplay.html("<b>Cell Data At ["+cellIndex+"] : </b>"+cellData);
});
The external js (part 1):
/*
* Get the status of the specified cell
* cellIndex : [2,3]
* @return : 0 or 1
* */
this.getCellState = function(cellIndex){
return sheetPrivate.cells[cellIndex[0]][cellIndex[1]].get();
}
The external js (part 2):
/*
* Get cell status
* cellIndex :[1,2]
* @return : 0 or 1
* */
getCellState : function(cellIndex){
return sheetModel.getCellState(cellIndex);
},
This is what shows from the source of the html page for the table. I will get the table layout from the debugger and post that as soon as I have edited from one line:
<div id="dynamicTable"></div>
<div id="J_calenderWrapper">
<table>
<thead></thead>
<tbody id="J_timedSheet">
</tbody>
</table>
</div>
I know this may be a duplicate but I have included this information in case it is not. I am looking at the possible duplicate post now. This is the table layout where all the cells are blue (a new blank table).
I have removed the rows from 2 to 27:
<div id="J_calenderWrapper">
<table>
<thead></thead>
<tbody id="J_timedSheet" class="TimeSheet">
<tr>
<td class="TimeSheet-head" style=""></td>
<td title="" data-col="0" class="TimeSheet-colHead " style="">Sun</td>
<td title="" data-col="1" class="TimeSheet-colHead " style="">Mon</td>
<td title="" data-col="2" class="TimeSheet-colHead " style="">Tue</td>
<td title="" data-col="3" class="TimeSheet-colHead " style="">Wed</td>
<td title="" data-col="4" class="TimeSheet-colHead " style="">Thu</td>
<td title="" data-col="5" class="TimeSheet-colHead " style="">Fri</td>
<td title="" data-col="6" class="TimeSheet-colHead rightMost" style="">Sat</td>
</tr>
<tr class="TimeSheet-row">
<td title="" class="TimeSheet-rowHead " style="">07:15am 07:45am</td>
<td class="TimeSheet-cell" data-row="0" data-col="0"></td>
<td class="TimeSheet-cell" data-row="0" data-col="1"></td>
<td class="TimeSheet-cell" data-row="0" data-col="2"></td>
<td class="TimeSheet-cell" data-row="0" data-col="3"></td>
<td class="TimeSheet-cell" data-row="0" data-col="4"></td>
<td class="TimeSheet-cell" data-row="0" data-col="5"></td>
<td class="TimeSheet-cell rightMost" data-row="0" data-col="6"></td>
</tr>
<tr class="TimeSheet-row">
<td title="" class="TimeSheet-rowHead " style="">07:45am 08:15am</td>
<td class="TimeSheet-cell" data-row="1" data-col="0"></td>
<td class="TimeSheet-cell" data-row="1" data-col="1"></td>
<td class="TimeSheet-cell" data-row="1" data-col="2"></td>
<td class="TimeSheet-cell" data-row="1" data-col="3"></td>
<td class="TimeSheet-cell" data-row="1" data-col="4"></td>
<td class="TimeSheet-cell" data-row="1" data-col="5"></td>
<td class="TimeSheet-cell rightMost" data-row="1" data-col="6"></td>
</tr>
</tr>
<tr class="TimeSheet-row">
<td title="" class="TimeSheet-rowHead bottomMost " style="">09:15pm 09:45pm</td>
<td class="TimeSheet-cell bottomMost" data-row="28" data-col="0"></td>
<td class="TimeSheet-cell bottomMost" data-row="28" data-col="1"></td>
<td class="TimeSheet-cell bottomMost" data-row="28" data-col="2"></td>
<td class="TimeSheet-cell bottomMost" data-row="28" data-col="3"></td>
<td class="TimeSheet-cell bottomMost" data-row="28" data-col="4"></td>
<td class="TimeSheet-cell bottomMost" data-row="28" data-col="5"></td>
<td class="TimeSheet-cell bottomMost rightMost" data-row="28" data-col="6"></td>
</tr>
</tbody>
</table>
</div>
This is the table layout where I have entered data (changed the cells background to blue color in the first column for the first 15 cells). I have removed the rows from 2 to 27:
<div id="J_calenderWrapper">
<table>
<thead></thead>
<tbody id="J_timedSheet" class="TimeSheet">
<tr>
<td class="TimeSheet-head" style=""></td>
<td title="" data-col="0" class="TimeSheet-colHead " style="">Sun</td>
<td title="" data-col="1" class="TimeSheet-colHead " style="">Mon</td>
<td title="" data-col="2" class="TimeSheet-colHead " style="">Tue</td>
<td title="" data-col="3" class="TimeSheet-colHead " style="">Wed</td>
<td title="" data-col="4" class="TimeSheet-colHead " style="">Thu</td>
<td title="" data-col="5" class="TimeSheet-colHead " style="">Fri</td>
<td title="" data-col="6" class="TimeSheet-colHead rightMost" style="">Sat</td>
</tr>
<tr class="TimeSheet-row">
<td title="" class="TimeSheet-rowHead " style="">07:15am 07:45am</td>
<td class="TimeSheet-cell TimeSheet-cell-selected" data-row="0" data-col="0"></td>
<td class="TimeSheet-cell" data-row="0" data-col="1"></td>
<td class="TimeSheet-cell" data-row="0" data-col="2"></td>
<td class="TimeSheet-cell" data-row="0" data-col="3"></td>
<td class="TimeSheet-cell" data-row="0" data-col="4"></td>
<td class="TimeSheet-cell" data-row="0" data-col="5"></td>
<td class="TimeSheet-cell rightMost" data-row="0" data-col="6"></td>
</tr>
<tr class="TimeSheet-row">
<td title="" class="TimeSheet-rowHead " style="">07:45am 08:15am</td>
<td class="TimeSheet-cell TimeSheet-cell-selected" data-row="1" data-col="0"></td>
<td class="TimeSheet-cell" data-row="1" data-col="1"></td>
<td class="TimeSheet-cell" data-row="1" data-col="2"></td>
<td class="TimeSheet-cell" data-row="1" data-col="3"></td>
<td class="TimeSheet-cell" data-row="1" data-col="4"></td>
<td class="TimeSheet-cell" data-row="1" data-col="5"></td>
<td class="TimeSheet-cell rightMost" data-row="1" data-col="6"></td>
</tr>
<tr class="TimeSheet-row">
<td title="" class="TimeSheet-rowHead bottomMost " style="">09:15pm 09:45pm</td>
<td class="TimeSheet-cell bottomMost" data-row="28" data-col="0"></td>
<td class="TimeSheet-cell bottomMost" data-row="28" data-col="1"></td>
<td class="TimeSheet-cell bottomMost" data-row="28" data-col="2"></td>
<td class="TimeSheet-cell bottomMost" data-row="28" data-col="3"></td>
<td class="TimeSheet-cell bottomMost" data-row="28" data-col="4"></td>
<td class="TimeSheet-cell bottomMost" data-row="28" data-col="5"></td>
<td class="TimeSheet-cell bottomMost rightMost" data-row="28" data-col="6"></td>
</tr>
</tbody>
</table>
</div>