Search code examples
jqueryjquery-bootgrid

Issue when appending a new row to a table and then trying to remove it


I'm having an issue when I try to remove a row that I recently appended to a table. I have 2 tables in the same view. The first table has some unassigned users, each row has its own buttton to assign them. When the button is pressed,the row is removed from the table and appended to the other table where the assigned users are shown.

In the second table (where the assigned users are shown) I wanna implement a button to unassign users, I implemented the same logic to remove the row from de table of assigned users and append it to the unassigned users table. The problem is that the row is not beign removed from the table.

I checked my code trying to remove a row that was preoloadedand it works fine, the problem is just trying to remove a row that has just been appended to that table, here are the functions I use for appending and removing rows:

function onAllocateBtn(row_id,row_fullname,row_university,row_state,row_city,row_membership,row_age,row_gender)
{
    var row_array = [{id:row_id,fullname:row_fullname,university:row_university,state:row_state,city:row_city,membership:row_membership,age:row_age,gender:row_gender,profile:"",roles:"",deallocate:""}];
    $("#data-table-assigned").bootgrid("append",row_array);
    var rows = Array();
    rows[0]= parseInt(row_id);
    $("#data-table-unassigned").bootgrid("remove",rows);
    $("#data-table-assigned").bootgrid("reload");
    $("#data-table-unassigned").bootgrid("reload");
}

function onDeallocateBtn(row_id,row_fullname,row_university,row_state,row_city,row_membership,row_age,row_gender)
{
    var removed_rows = Array();
    removed_rows[0]= parseInt(row_id);
    console.log("removed_rows: " + removed_rows);
    $("#data-table-assigned").bootgrid("remove",removed_rows);
    $("#data-table-assigned").bootgrid("reload");
    $("#data-table-unassigned").bootgrid("reload");
}

Thanks in advance


Solution

  • Check the id you're sending.

    Bootgrid performs a validation for the value type. Maybe your id is a string and not an integer.