oTable.fnDeleteRow(nRow) ?? nRow is a string

oTable.fnDeleteRow(nRow) ?? nRow is a string

mlotfimlotfi Posts: 60Questions: 5Answers: 0
edited November 2014 in Free community support

I have a problem, I want to delete a row from the table with fnDeleteRow , but I don't have an id number, just string, can you please help me on how to deal with this ?

IN HTML :

 <tbody>
            <logic:iterate id="mdataenv" name="metadataEnvList">
                <tr  id='<bean:write name="mdataenv" property="interfaceEnvironment"/>'>
                    <td><bean:write name="mdataenv" property="interfaceEnvironment"/></td>
                    <td><bean:write name="mdataenv" property="disabled"/></td> 
                    <td><bean:write name="mdataenv" property="creatorId"/></td>                 
                     <td class="center"><ichtml:dtfmt vDate="${mdataenv.createdAt}"/></td>
                    <td><bean:write name="mdataenv" property="updaterId"/></td>
                     <td class="center"><ichtml:dtfmt vDate="${mdataenv.updatedAt}"/></td>
            
                      <td class="center">
                      <html:link href="JavaScript:void()" styleId="gglobal" styleClass="button delete" style="margin:10px;margin-right:30px;">Delete</html:link>
                    </td>                     
                </tr>
            </logic:iterate> 
       </tbody>

in JS :

  var nRow = $(this).parents('tr')[0];
            alert(nRow.id);   <------------------ ------------------------------- is a string
            oTable.fnDeleteRow(nRow);

edited by Allan Formatting

Replies

  • AaronMAaronM Posts: 4Questions: 0Answers: 0
    edited November 2014

    Check the documentation for row().remove(), when I test this using v1.10.4 the following works;

    $('#devices-table tbody').on('click', 'tr', function () {
        self.selectedRow(this);
    });
    
    $('#delete-device-btn').click(function () {
        dataTable.row(self.selectedRow())
            .remove()
            .draw();
    });
    

    The above example stores the row.node() differently to the documentation, but the end result is the same.

  • allanallan Posts: 62,524Questions: 1Answers: 10,273 Site admin

    Agreed - use the new API for 1.10. However, the code you have looks like it show work just fine - you are passing in the node (not the id string - that has no relevance). If it isn't working, please link to a test case, as required in the forum rules.

    Allan

This discussion has been closed.