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

<table id="checkLossItem" class="table table-hover searchtable">
                        <thead>
                            <th>Choice</th>
                            <th>Loss item</th>
                            <th>Loss content</th>
                            <th>Contact information</th>
                            <th>operation</th>
                        </thead>
                        <tbody>
                            {^{for prpLscheduleItemsDetailVoList}}
                                <tr>
                                    <td>
                                        <input type="checkbox" class="switchbox check" 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" class="btn btn-default btn-inner switchbtn" >
                                            Normal scheduling
                                        </button>
                                    </td>                           
                                </tr> 
                            {{/for}}
                            {^{for prpLscheduleItemsDetailAddVoList}}
                                <tr>
                                    <td>
                                        <input type="checkbox"  class="switchbox check" 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" class="btn btn-default btn-inner btn-removethis">
                                            <i class="fa fa-trash-o fa-lg"></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.

Posted on Thu, 13 Feb 2020 14:06:07 -0500 by russthebarber