mercredi 26 juillet 2017

Load nested j-Query DataTable on load if checkbox is checked?

I have two views one for create and second for update. During creation I am loading the nested table through j-Query if the parent row is checked. e.g. I have 5 rows in the parent table and if I check all of them I will have different nested j-Query data-table for all of them. Something like this.

Following is my code:

$('#tblEmployees').on('click', 'input[type="checkbox"].checkbox', function () {

    if (oTable.fnIsOpen($(this).closest('tr'))) {
        oTable.fnClose($(this).closest('tr'));
    } 
    else 
    {
        oTable.fnOpen($(this).closest('tr'), getTasks($(this).closest('tr').children(value), "info_row");
    }
});

Here, getTasks is a function that returns the table.

Now , the problem is edit view. I want to perform this action on load. On load, I need to check if checkbox is true then open the child table. But it is now working as expected. Following is my code:

if($('#tblEmployees input[type="checkbox"].checkbox').is(':checked')){

   oTable.fnOpen($(this).closest('tr'), getTasks($(this).closest('tr').children(value), "info_row");

 }




Aucun commentaire:

Enregistrer un commentaire