Tell me about it

I'm nearly done with the datagrid setup in this app. Just one little niggle.
I have an option to delete rows. By clicking a button in the title bar a delete button becomes visible on each row.
Click the button and it deletes the row and refreshes the datagrid.
The one issue is that if you try and delete the last row the grid does not refresh.
The data is in fact gone. I tested that by refreshing the grid from another button(that removes the last row)
So my question is: what is it about the grid that makes my code behave differently if there is only one row remaining..?
The button to show the delete buttons:
Code: Select all
on touchEnd pId
mobGUIUntouch the long id of me
if field "label" of me is "Done" then
put "Edit" into field "label" of group "ButtonEdit"
put the dgProps["Row Template"] of group "DataGrid 1" into theRowTemplate
set the visible of button "ButtonDelete" of theRowTemplate to false
dispatch "ResetList" to group "DataGrid 1" of card "main"
else
put "Done" into field "label" of me
put the dgProps["Row Template"] of group "DataGrid 1" into theRowTemplate
set the visible of button "ButtonDelete" of theRowTemplate to true
dispatch "ResetList" to group "DataGrid 1" of card "main"
end if
end touchEnd
then the code in the delete button of each row:
Code: Select all
on mouseUp pBtnNum
put the dgHilitedLines of group "DataGrid 1" into theLine
dispatch deleteLIne to group "DataGrid 1" with theLine
end mouseUp
this seems to refresh the grid after the line is deleted perfectly well unless its the last line..?
If i add this to the end of that mouse up handler it breaks it:
Code: Select all
dispatch "ResetList" to group "DataGrid 1" of card "main"
Yet my gut tells me thats exactly what it needs after removing the data from the last row.