-
FEATURED COMPONENTS
First time here? Check out the FAQ!
When we display a list of items on a screen that has more rows than what we can display on one page; the user advances to the next page and then wants to insert a new record, the new record is added in the beginning (first page of the list). As the user is on the other page, he will not be able to see this new inserted record.
My requirement is that when this scenario happens, after inserting a new record the application must navigate automatically to the first page and set the focus on the first newly created line.
In ViewModel, I am using:
/**
* On add new action command.
* allRecordsInDb -- the list of all my objects
*/
@Command
@NotifyChange({ UIConstants.ALL_RECORD_IN_DB, UIConstants.DISPLAY_EDIT })
public void onAddNew() {
Currency object = new Currency();
object.setEditStatus(true);
allRecordsInDB.add(0, object); // add the object on the beginning of the list.
}
May anyone have an idea how I can achieve this?
I tried to use a zscript function with this binding command but I didn't have chance to overcome this challenge because it seems not to be supported.
<zscript><![CDATA[
void changePage(){
int cp = grid.getPaginal().getActivePage();
System.err.println(cp);
grid.getPaginal().setActivePage(0);
int cp2 = grid.getPaginal().getActivePage();
System.err.println(cp2);
}
]]></zscript>
Thank you.
Emma
I think it is quite simple if you bind the activePage property to the view model. Changing the value of the currentPage will navigate automatically to the page you want:
<grid activePage="@bind(vm.currentPage)" />
/costas
/**
* On add new action command.
* allRecordsInDb -- the list of all my objects
*/
@Command
@NotifyChange({ UIConstants.ALL_RECORD_IN_DB, UIConstants.DISPLAY_EDIT, "currentPage" })
public void onAddNew() {
Currency object = new Currency();
object.setEditStatus(true);
allRecordsInDB.add(0, object); // add the object on the beginning of the list.
setCurrentpage(0); // navigate to the first page of the grid
}
The attribute activePage works effectively. And as seen above remember to add @NotifyChage("currentPage").
<grid activePage="@bind(vm.currentPage)" />
Many thanks to costas.
Asked: 2015-08-11 15:24:40 +0800
Seen: 35 times
Last updated: Aug 19 '15