quantopian/qgrid

grid does not support add_rows on an empty dataframe. Could we stop the user from removing the last row?

camilog04 opened this issue · 0 comments

Environment

  • Python 3.8.8
  • pip installed

Description of Issue

  • What did you expect to happen?
    when the dataframe is empty, the add row botton from the tool bar does not work.
  • What happened instead?
    I expected that the widget add a row

Reproduction Steps

  1. initialize the qgrid widget with one row
  2. show the widget with the tool bar option
  3. delete all the rows
  4. click the 'add_row' button
    ...

What steps have you taken to resolve this already?

A solution to this is to prevent the users from deleting the rows. This can be accomplished by adding an empty check to the remove_rows method:

  • if self._df.shape[0] <= 1:
    
  •     # Optionally throw a warning here
    
  •     return selected_names
    

...

Anything else?

Another solution is that when the dataframe is empty there is a constroctor of a 'default' row but but this would be more difficult to scale.
...