The difference between using $. view() and using find() to get the row number of a datatable row

<table id="checkLossItem"> <thead> <th>Choice</th> <th>Loss item</th> <th>Loss...
<table id="checkLossItem"> <thead> <th>Choice</th> <th>Loss item</th> <th>Loss content</th> <th>Contact information</th> <th>operation</th> </thead> <tbody> {^} <tr> <td> <input type="checkbox" name="itemsCheck" checked="checked"/> </td> <td> <input list="lossTypeold" class = "itemName" data-link="itemName" required="required" readonly="readonly"> <datalist id="lossTypeold"> <option>Main vehicle</option> <option>Three party vehicle</option> <option>Material damage</option> <option>Human injury</option> <option>Robbery</option> <option>Other</option> </datalist> </td> <td> <input type="text" name="" data-link="itemContent" readonly="readonly" required="required"> </td> <td> <input type="text" name="" data-link="phone" readonly="readonly" required="required"> </td> <td> <button type="button" > Normal scheduling </button> </td> </tr> {{/for}} {^} <tr> <td> <input type="checkbox" name="itemsCheck" checked="checked" disabled="disabled" /> </td> <td> <input list="lossTypenew" class = "itemName" data-link="itemName" required="required"> <datalist id="lossTypenew"> <option>Main vehicle</option> <option>Three party vehicle</option> <option>Material damage</option> <option>Human injury</option> <option>Robbery</option> <option>Other</option> </datalist> </td> <td> <input type="text" name="" data-link="itemContent" required="required"> </td> <td> <input type="text" name="" data-link="phone" required="required"> </td> <td> <button type="button"> <i></i> </button> </td> </tr> {{/for}} </tbody> </table>

There is a problem in developing the foreground. When I click a line, I need to get the line number index of this line. Think of using $. view() to get the current line
var index = $.view(checkarray[i]).getIndex();

However, things are not so simple. It is found that the sequence number of prpLscheduleItemsDetailVoList is always retrieved in this way, and the sequence number of prplscheduleitemsdetaldaddvolist is not retrieved. So in summary, $. view() is a row below the current set, not at the entire table level. Then I studied how to get the row number under the whole table
var index = $("#checkLossItem").find("tr").index($(checkarray[i]).parent().parent())-1;
The sequence number obtained in this way needs to be subtracted by 1. It starts from 1.

13 February 2020, 14:06 | Views: 6804

Add new comment

For adding a comment, please log in
or create account

0 comments