grid refresh and cancel button

hi sir
I am having one problem in grid and I tried all the way nut unable to fix it.
I am having Add new student so it will give new empty row in grid, if I am entering any data its ok save button is working ,but incase that empty row i don’t want so i am clicking on cancel button. but that grid is not refreshing that empty grid is still there.
I am using :
grid.getEditor().addSaveListener(e → {
ListDataProvider dataProvider = (ListDataProvider) grid.getDataProvider();

grid.getEditor().addCancelListener(e → {
//ListDataProvider dataProvider = (ListDataProvider) grid.getDataProvider();

how to fix it.
please help me out to fix it.