Reputation: 7197
I am looking for a way to get value from cell with index 13. I was able to get parent element (which is row
), but now I have problem how to get value from cell from that row.
My code - here's how I've got the row:
$(event.currentTarget).parent().parent()
This is what I've got from call above:
[tr.jtable-data-row]
Cell looks like this (button inside is making the call):
<td><button ng-click="ChangeMEST_STA($event)" class="ng-scope">V pripravi</button></td>
And the angular function (empty for now):
$scope.ChangeMEST_STA = function ($event) {
cMEST_STA = "";
cMEST_CDO2 = "";
/* change status */
}
And here is the whole row:
<tr class="jtable-data-row jtable-row-even" data-record-key="110002001"><td>110002001</td><td>Pločevinke</td><td>Mali kuharski mojster</td><td>15</td><td>KOS</td><td>1234567891234</td><td>MK27Q3 (V4FSPY)</td><td>VjRGU1BZIE1L</td><td><input type="checkbox" style="width: 15px; height: 15px;"></td><td><input type="text" title="Vnesi količino" style="width: 30px" value="1"></td><td><i id="tdAddToCart" class="glyphicon glyphicon-shopping-cart ng-scope" style="font-size: 20px; color: black; cursor: pointer;" ng-click="AddToDeliveryList()"></i></td><td style="display: none;"><input type="text" style="width:200px; display:none;" value="110000021"></td><td style="display: none;">1</td><td><button ng-click="ChangeMEST_STA($event)" class="ng-scope">V pripravi</button></td></tr>
How to use that call to get value from cell? I don't know how to combine HTML with angularjs. I would like to use something like: td:nth-child(12)
Upvotes: 0
Views: 885
Reputation: 3950
To find your TD, use:
$(".jtable-data-row.jtable-row-even").find("td")[12];
To set the value of it, use:
$($(".jtable-data-row.jtable-row-even").find("td")[12]).text(222222);
Upvotes: 1
Reputation: 5985
Oh, I see your HTML now.
Try this:
HTML
<tr class="jtable-data-row jtable-row-even" data-record-key="110002001">
<td>110002001</td>
<td>Pločevinke</td>
<td>Mali kuharski mojster</td>
<td>15</td>
<td>KOS</td>
<td>1234567891234</td>
<td>MK27Q3 (V4FSPY)</td>
<td>VjRGU1BZIE1L</td>
<td><input type="checkbox" style="width: 15px; height: 15px;"></td>
<td><input type="text" title="Vnesi količino" style="width: 30px" value="1"></td>
<td><i id="tdAddToCart" class="glyphicon glyphicon-shopping-cart ng-scope" style="font-size: 20px; color: black; cursor: pointer;" ng-click="AddToDeliveryList()"></i></td>
<td style="display: none;"><input type="text" style="width:200px; display:none;" value="110000021"></td>
<td style="display: none;">1</td>
<td><button ng-click="ChangeMEST_STA($event)" class="ng-scope">V pripravi</button></td>
</tr>
Javascript
$(event.currentTarget).closest('tr').find('td:nth-of-type(13)').text();
Upvotes: 0