How to add a new row below to click a row using jquery

enter image description here

When I click on the second column of the click, I call the method below

function getListOfList(primaryId, isFlat, col) {
        alert(primaryId)
        $.ajax({
            url : ("/" + serverURL + "/dataGrid/getChilds"),
            type : "POST",
            data : {
                primaryId : primaryId,
                isFlat : isFlat,
                column : col
            },
            success : function(result) {
                                }
        });
    }

it will return

returnMap as JSON ==========================[statusFlag:SUCCESS, data:[[<a onclick="viewEmpDetails('56374e74f45f064d33b57583','false','UniqueId')" title='View' style='cursor:pointer'><i class='ace-icon fa fa-search-plus grey' style='width:30px;'> </i></a>, <a onclick="getChilds('8','false','UniqueId')" title='View' style='cursor:pointer'><i class='ace-icon fa fa-search-plus grey' style='width:30px;'> </i></a>   Bhagyawan, 02/02/49, 02/08/81, 15/02/1836, 15-Jan-2012, 10-Feb-25]]]

part of the result data is actually row data. which has two row data and maybe three depending on the query I need to add below to click the row.

I am dynamically creating a table

<div class="row">
        <div class="col-xs-12">

            <table id="data-grid-table-tree" class="datasetTable">
              <tr>
                    <th>View</th>
                    <th align="left">${session.data}</th>
                    <g:if test="${session.fieldsToFetch }">
                    <g:each in="${session.fieldsToFetch}"  var="column">
                        <th >${column }</th>

                    </g:each>
                    </g:if>
                                      </tr>
              <tr>
                   <g:each in="${session.treeGridJsonObject}"  var="lists">
                    <tr align="left">
                        <g:each in="${lists}"  var="list">
                               <td align="left">${raw(list)}</td>

                        </g:each>
                    </tr>
                   </g:each>              

            </table>

Any help!

+4
source share
1 answer
<table border="2">
    <tr><td>test1</td></tr>
     <tr><td>test1</td></tr>
     <tr><td>test1</td></tr>
</table>


$(document).ready(function(){
    $('table tr:nth-child(1)').after('<tr><td>test2</td></tr>');
});

$ ('table tr: nth-child (1)') . Take this as your selected row.

Convert your result records to html table row table, then use the above code to add your table row.

jsfiddle

0

Source: https://habr.com/ru/post/1614142/


All Articles