0

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)

6
  • could you add the area of the html template to see how your iterating over the data. Commented Dec 2, 2016 at 16:26
  • $(event.currentTarget).closest('tr.jtable-data-row:nth-of-type(12)') ? or $(event.currentTarget).closest('tr').eq(12); Commented Dec 2, 2016 at 16:29
  • Is it also possible to set value in that cell? One of the cells has button on which I would like to change text. Commented Dec 2, 2016 at 16:32
  • @ntgCleaner - this is not working, I've got empty object. Commented Dec 2, 2016 at 16:36
  • @FrenkyB Could you please include the HTML code so we know what you're working with? Commented Dec 2, 2016 at 16:37

2 Answers 2

1

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);
Sign up to request clarification or add additional context in comments.

Comments

0

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();

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.