How to apply Paging in smartgwt Listgrid - gwt

I have to show around more than 10,000 records in a listgrid. My code is working fine but I am facing performance issue it takes too much time for it.
I want to apply pagination in Listgrid, so I can increase my listgrid performance. I find the following method documentation mentioned about paging but I was not able to apply it. Can any one please explain how can I use this method??
protected void transformResponse(DSResponse response,
DSRequest request, Object data)
http://www.smartclient.com/smartgwt/javadoc/com/smartgwt/client/data/DataSource.html#transformResponse%28com.smartgwt.client.data.DSResponse,%20com.smartgwt.client.data.DSRequest,%20java.lang.Object%29

By using pagination for listgrid you manually prepare pagination bar and put some controls onclick that controls the listgrid load the data. I am trying it's working and we are sure we increase grid performance.

Related

How Do You Filter and Sort Data in a CollectionView

I have a CollectionView on a page that is displaying data from a List<> of items. I do sorting and filtering in a code behind on the page by changing the List with LINQ, and then setting the BindingContext of the view, like this:
MyView.BindingContext = FilteredData;
On IOS this works fine, every time, no problem. On Android, I can change the data a few times (it varies - normally three to five) and then the page doesn't display any data. In the debugger I can check and still see the ItemsSource has all of the items, but nothing is displayed. I then "switch" to my other view on the page, which is done by hiding one DataGrid row and showing another, then "switching" back. The data still isn't displayed, but after I do that I can run the code again that does the sorting and filtering and it starts working again - the data is displayed on the page. Not only that, but after I do that, it works every time from that point forward on Android.
I've spent hours trying every thing I can think of to try and find an event or property or anything that would indicate when this problem occurs so I can try and find a work around for it. I'm at a complete loss; wondering if there are suggestions for how to capture and/or fix this problem.
I did find a combination that worked to resolve this issue. I changed the page so that the CollectionView at issue is in the Grid row that has a non-zero (i.e. visible) height when the ContentPage loads. After doing that, the code works as expected. Previously, it was in a Grid.Row whose height was set to an absolute 0 when the page loaded, and then the height was changed to a non-zero value when a button was clicked.
FWIW, this is similar to other issues I've seen with MAUI on Android, where the visibility of certain controls as well as the order in which you modify them can interfere with rendering data binding results.
I solved sorting using a SortedList and made the list items inherit from IComparable, but I don't love the solution because a SortedList is not an ObservableCollection, and because implementing IComparable can be tricky and leaky.

Auto-refresh a ListView within a ViewPager?

I'm having a bit of trouble approaching an auto-refresh design I want to implement.
Currently I have a TitlePageIndicator that sets its view pager with a PagerAdapter.
Each page in the view pager is a listview that is constructed based on a list of date strings.
In my instantiateItem() method, I call an AsyncTask to load data based on the date. This works well, and loads the way I want.
I recently changed all my listviews to PullToRefresh list views, in order to make sure a user could update the data on a date they wished to have the most up-to-date info on. (This also works the way I desire).
However now I want to somehow refresh a certain date in the view pager (Current date for instance) - every 60 seconds. So I'm not refreshing all the listivews in the viewpager, i'm just refreshing the one I want.
I started making a timer thread based on this :
Update TextView within custom ListView
But soon got very stumped and I'm not sure what to do next..
Can someone point me in the right direction?

Ext-GWT 3.0 Grid Mouse Events

I have a grid which gets populated from the database and works fine. Now I want to add a mouseover event to this grid and display a tooltip text which shows all the column values in multi-line fashion for the highlighted record. The business case here is that there are quite a few columns that are being displayed in the grid and the user would like to have a quick preview instead of horizontally scrolling all the way to the end, before selecting the record. Squeezing all these columns to fit into the screen is not a clean solution in this case.
I have tried looking through all the available methods in the GXT 3.0 API for Grid and GridView but couldn't find anything to get the highlighted records. There are a couple of events for MouseMove, MouseDown and MouseClick but none for MouseOver.
I tried various forums as well to find a solution but there doesn't seem to be one yet so thought it might be useful for others as well if I start this thread.
Please note that this issue is not related to Ext-JS. The version I am using is Ext-GWT 3.0.1.
Thanks
MouseMove IS the one you want. It's only fired when the mouse is over the widget.
Alternatively, you can sink a DOM event to the widget by using:
DOM.sinkEvents(widget.getElement(), Event.ONMOUSEOVER);
in your widget's constructor or onLoad method, and then override the widget's onBrowserEvent:
#Override
public void onBrowserEvent(Event event){
final int eventType = DOM.eventGetType(event);
if(eventType == Event.ONMOUSEOVER) {
//DISPLAY THE INFO
}
}
This is definitely harder than directly adding a handler but pretty customizable. You can choose either one.
BTW you might want to get the position of mouse by using:
mouseX = DOM.eventGetClientX(event);
mouseY = DOM.eventGetClientY(event);
You could accomplish this by creating a custom Cell, and passing that to the grid's specific ColumnConfig.
With the custom Cell, you have access to all the events you would need.
Once you have access to the info you need, displaying it can be done in many ways. GXT provides a lot of solutions for this. Quicktips may be the way to go here though.

GWT Cell Callback

I am writing a custom cell for GWT, but the data to be displayed will be fetched asynchronously (REST call). How do I make the rendering asynch for the cell?
I see ImageLoadingCell shows a spinner, then shows the image when it is loaded, this is done by a browser event, however, since mine is a REST call, I can't use the onBrowserEvent() method, and hence, I don't have a handle to the Element, to refresh its information.
I'm thinking maybe I have to do this through table.refresh()? I'd really like the render method to trigger the fetching however.
If you look at the goals of cell widgets, then I don't think this is possible and definitely not desirable :
Cell widgets (data presentation widgets) are high-performance,
lightweight widgets composed of Cells for displaying data.
I have faced a similar problem : suppose you have a Contact with a List of tags but only the tagIds are stored with the contact. To visualize the tags in the table, you would have to make callbacks to the server to get the names.
The solution is in using the adapter pattern. Create a ContactAdapter that holds the contact and the actual tags instead of the tagIds. Pre-fill the contact adapters with the tags based on the tagIds and set the List as the datasource for your celltable.

A GWT CellTable with frozen header and initial column

I need to freeze the first column and first row of data in a CellTable, so that users can scroll through the data but still see the labels on the "axes." The first column should scroll when the user scrolls up and down, and the header row should scroll when the user scrolls left and right. Think "Freeze Panes" in Excel.
I'm using GWT 2.1 and am willing to write my own widget to do this if no solutions already exist. My question is a two-parter:
Do any widgets already have this behavior?
Any suggestions if I'm going to implement this myself?
Thanks!
I implemented a solution myself. Check out http://larkolicio.us/ScrollTable/ExperimentTables.html
It's a LayoutPanel with three AbsolutePanels inside it. The frozen columns are a CellTable, the main part is a CellTable, and the header is a Grid - I could find no way to set the width of a CellTable column! A ScrollHandler links the main part to the two frozen parts. There is a little bit of delay - I'd appreciate it if someone could find a way to get rid of the lag between the sections.
I got it working to a point that I could use it, and stopped. It is not a general-purpose widget. Please feel free to use it at your own risk.
This implementation is quite good. I have just tested it. It however needs some changes made to support asynchronous loading. GWT Issue 188 covering similar request for enhacement was created on Oct 2006?!
Thanks for sharing.