Paging data is refreshing on navigation in jetpack compose - android-jetpack-compose

I'm getting some data from my database like this
Pager(PagingConfig(pageSize = PAGE_SIZE)) {
songRepo.getSongs()
}.flow.cachedIn(viewModelScope)
and I collect it in the UI using collectAsLazyPagingItems(), but whenever I navigate to another screen and I go back the data is clearing.
Is there a solution to this or I should create my own pagination without Paging?

You will have to create a new instance of Pager every time you come back from a new screen.
Pager(PagingConfig(pageSize = PAGE_SIZE)) {
songRepo.getSongs("albumId",false )
}.flow.cachedIn(viewModelScope)

Related

Angular UI Grid - reload data not working

I am using ui-grid. The left panel has search filters and a search button which populates data into grid in right panel (initially grid renders without data). Application has two separate controller one for search panel and another for grid.
Now i am using shared service to pass data from searchController to gridController but data in grid is not displaying. I can see gridOptions.data is set by that function.
console.log( $scope.gridOptions.data)//length is 2 here.
If i tried to call http.get directly from grid controller and bind data in success object, grid populates properly.
I tried different methods to refresh/reload (see below) the grid but no results.
$scope.gridApi.core.refresh();
Any suggestion.
You have to assign data to $scope.gridOptions.data in your grid controller.
I assume, you are getting that data from your shared service.
Also ensure, search button generates an event which fetches data from shared service, and assigns it.

How to reload parent view in Vaadin without table reseting sort order

I'm using PagedFilterTable in Vaadin to manage pagination. When loading default page, I have set something like this - and I include sorting by some field:
if(this.sortField != null){
table.setSortContainerPropertyId(this.sortField);
table.setColumnWidth(this.sortField, 80);
table.setSortAscending(true);
table.sort();
}
So that happens when the page is loaded and that is fine. After I submit new entry (entries are being added through new, popup window), table gets new row, but the table loses it's sort order in view after popup closes, so sorting is no longer keeped. Problem is I do not know how to get to that table element from that popup window and set sorting again. Why table is being updated and I see it, and sort doesen't? Problem is bigger because I have both windows in separate files and seems to me I can't grab table element easily without modifiying the logic because I am in another window.
How to reload table so that the sort stays same?
I managed to do this after submit:
getUI().getPage().reload();
With that it works, but I am not satisfied. After that line of code, everything reloads again (meaning all queries execute again). Result is good but I don't want after submit whole reloading of page happens (also because none of my other buttons do reload). So I would like only to reload table in parent window.
How can I grab table object from outside window and for example set it's change to immediate and correct change?
Something like this I suppose needs to be written:
getParent().getUI().setImmediate(true);
?
Or better question, how to manage to table sort remains the same after inserting new entry through new window?
I managed to solve it. On the parent window in the windowCloseListener I just added:
myTable.refreshTable(data);
myTable.sortTable(); // my custom method that was Invoked on the page load too

Refresh view in Acumatica

I have following situation: grid1 and grid2. After user press at button I generate records for grid2 with help PXDatabase.Insert. I need PXDatabase.Insert due to performance reason, so please don't say I have to use view. How can I refresh grid2 without refreshing whole screen. For example grid has button refresh. How to call it automatically?
You can force application to refresh a grid by invoking RequestRefresh() on the view which is bound to your grid2. For example, in the discount calculation engine, you will find this code, to force system to refresh discount details grid:
discountDetails.View.RequestRefresh();

How to capture DialogViewController refresh in Xamarin.iOS?

I am using Xamarin to build a simple app. In my app I use a series of classes that inherit from DialogViewController. In some cases, when the user clicks on an item, I use:
NavigationController.PushViewController( new DialogViewClass() , true );
This when the DialogViewClass() starts and sets up a new view, it might alter the state of the data that requires my current Dialog to be refreshed.
When the user finally backs out of the stack, and reshows my dialog, how do I capture "the event" that says my dialog is being redisplayed, so that I can update my view with current information?
Found my answer. In the class that inherits from DialogViewController, add this override:
override void ViewWillAppear( bool animated ) {
base.ViewWillAppear( animated );
// Show the page
}
In my case, simply rebuilding the interface based on the values in my constructor is good enough whether the page is being loaded for the first time, or is being reloaded after a POP action.

MonoCross Example using "MXTouchViewGroup*" in a MonoCross.Touch application

Does anyone have example code illustrating how one would use the "MXTouchViewGroup*" code in the framework to create/use a tab bar at the bottom. Looking at code for MXToughViewGroup*, it isn't 100% clear how I would setup/use the navigation framework with a tab bar. Unfortunately the MonoCross book also has no examples of this case.
Any help would be appreciated.
Thanks in Advance.
So after poking around in MonoCross source, I've figured out how one would use a MonoTouch/iOS tab bar while using the MonoCross pattern, and specifically while continuing to use MonoCross.Navigation to move around your app:
//------- MonoCross Shared Application
// Main Menu
NavigationMap.Add("Menu/Tab1", new Tab1Controller());
NavigationMap.Add("Menu/Tab2", new Tab2Controller());
NavigationMap.Ass("Other", new OtherController());
// Set default navigation URI
NavigateOnLoad = "Menu/Tab1";
//------- MonoCross.Touch Container
// init monocross application
MXTouchContainer.Initialize(new SharedApplication(), this, window)
// Add view to container as usual
MXTouchContainer.AddView<ModelTab1>(typeof(Tab1View),ViewPerspective.Default);
MXTouchContainer.AddView<ModelTab2>(typeof(Tab2View),ViewPerspective.Default);
MXTouchContainer.AddView<ModelOther>(typeof(OtherView),ViewPerspective.Default);
// Create a MXTouchViewGroup, with items representing tab items
MXTouchViewGroupItem[] menuItems = new MXTouchViewGroupItem[] {
new MXTouchViewGroupItem(typeof(Tab1View),"Tab 1!",""),
new MXTouchViewGroupItem(typeof(Tab2View),"Tab 2!",""),
};
MXTouchViewGroup tvg = new MXTouchViewGroup(new MXTouchViewGroupTabController(),menuItems);
// Add the group to MXTouchContainer.ViewGroups
List<MXTouchViewGroup> ltvg = ((MXTouchContainer)MXTouchContainer.Instance).ViewGroups;
ltvg.Add(tvg);
// navigate to to starting location now
MXTouchContainer.Navigate(null,MXTouchContainer.Instance.App.NavigateOnLoad);
In the shared app, create controllers derived from MXController as usual and add them to the NavigationMap. Absolutely nothing special to be done in the "Shared Application"
In The MonoCross Container, you add views derived from MXTouch*View as usual to the container as usual as well. What is done differently is to create a "MXTouchViewGroup" with one "MXTouchViewGroupItems" created for each tab; each "MXTouchViewGroupItem" has one of your views associated to it. You'll want to create an appropriate "MXTouchViewGroup" item for your tab bar, and then add the group to your "MXTouchContainer" as shown, and then let the framework navigate to the first view as usual.
The result of all this is that when navigating to a view that is in a "group" (i.e. "Tab1View" or "Tab2View"), the framework will automagically render a tab bar with the view, without any further intervention. If you navigate to a view that isn't in a "group" (i.e. "OtherView"), the tabbar will not render.
That's it.

Resources