After add/delete/add of subgrid, subgrid shows only white grid with no rows

  1. Add subgrid from row 7
  2. Delete subgrid from row 7
  3. Add subgrid back to row 7
  4. Subgrid exists but shows only white with no rows. How do I fix this?
    I have attached a screenshot.

// delete code
subgrid = maingrid.cells(row,0).getSubgrid();
if (subgrid)
{
subgrid.destructor();
maingrid.setCellExcelType(row,0,“rotxt”);
maingrid.cells(row,0).setValue(‘’);
}

// add subgrid code
maingrid.setCellExcelType(row,0,“sub_row_grid”);
maingrid.cells(row,0).setValue(‘1,2,3,4,5’);

Regards,

Rich

Hello.

Such dynamic destruction/creation of the subgrid cell is not supported.
Please, try to avoid calling the subgrid.destructor() method in this case.
It is better to close your subgrid:

maingrid.cells(row,0).close()

and change its col type:

maingrid.setCellExcelType(row,0,“rotxt”);

than you can call

maingrid.setCellExcelType(row,0,“sub_row_grid”);

to come back to the created earlier subgrid

Thanks, I tried the solution and it does remove +/- but even with the clearAll() on the subgrid, it leaves the data from the subgrid in the first column. Adding cells(row,0).setValue() = “”; removes the data but the re-add only adds back the subgrid but without the new data.

I decided the simplest solution was to keep one row in the subgrid and place a message in description field: No Data To Process. Adding data / deleting data / re-adding data works fine due to the subgrid never being deleted.

maingrid.cells(row,0).open()
subgrid.clearAll();
maingrid.cells(row,0).close()
maingrid.setCellExcelType(row,0,“rotxt”);

Regards,

Rich