well, the intended design is NOT to reload page if a row is deleted (better 
user experience). 
Small corner cases are "delete every row in the page and be "forced" to 
click on next page to have new records", etc.....

Anyway, you can intercept delete operations....

deletable = request.vars.stoptoyingaround and False or True
if request.args(0) == 'delete':
      if db(db.parameter).count() <= 1:
          response.flash = 'deleting the last row is not allowed'
           redirect(URL('yoururl', vars=dict(stoptoyingaround=1)))
      .......

caveat: if you're using the "args" argument to SQLFORM.grid() 'delete' 
would be the first arg after the "base" ones.

if you like to have your users to play with the delete button when there is 
1 row left (and not harm your database while playing), you can skip the 
deletable assignement based on request.vars.
As a nice side effect, you can count your table only when it's needed ;-)


Reply via email to