I work on a mobile app which shows a stream of data fetched from the server. Initially the app fetches first page with 10 items. When user scrolls down, the app fetches the second page with next 10 items (in other words - infinite scroll). The problem I have is that when the user A fetches page number X it is possible, that the user B creates a new content on the server which modifies the resultset available for the user A. This means that if the user A tries to fetch X+1 page, it will contain previous item(s) which were "pushed back" by the new content. How to solve it? I came out with two solutions but I don't know which is better:
the mobile app remembers ids of already shown items and if in the next page there is an item which was already shown, it is not shown again.
the app remembers date of creation of the first item from the first page. When it fetches next pages, it additionaly sends this date to the server which adds this date to the sql query in order to maintain the same resultset
What do you think? Which is better? Are there better solutions?
UPDATE:
Imagine that I have a table 'queries' with columns 'queries_id' (integer, primary key), 'date_created' (timestamp). My query looks like this: select * from queries order by date_created desc. It is not true that date_created date_created increments with primary key incremenatation. I paginate data with Spring Data using Pageable object. Now the problem is that if new rows are created and they have date_created newer then previous newest row then they modify resultset.
This happens because you do the pagination based only on the date_created.
I assume that you do your query with ORDER BY date_created DESC and you offset for the current page.
To avoid your problem you need to add the last id of the previous fetch in your query. I.e. queries_id < last_id ORDER BY date_created .... etc
Related
I have a sheet that multiple people are working on, but only on certain rows in the sheet that they mark with their name. There is a master sheet where they are marking which ones they're working on, then a tab for each named person. The tab with their name gets populated using a "=QUERY(Master!A3:AX,"select * Where L='NAME'")". The goal of the tab is so they can work on their own stuff without having to scroll through the thousands of rows to find their next entry. Getting the info from the master to the tab is working fine, but when they are working on their tab, they add information to a few new columns at the end of the query. This is where my problem lies, when they go and tag another entry on the master as theirs, the columns they added information to already do not move with the entrys, they just get pushed up or down depending on the new entry placement.
Is there something I can do that will still pull in the data from the master sheet to the corresponding tab, but then keep what the staff is actually entering/working on, to remain in line with the entry that got pulled in? The whole process is sort of useless if their work is not retained as they are working through it.
For example, the query pulls in column A-L, then they are adding information to column M and N for the management to read and make decisions off of their input. I need the information they enter into column M and N to remain with the row the query originally pulled in. The master is sorted by a unique number in column A that needs to remain in that order, so they may add new entries randomly as they assign rows to themselves.
I am trying to modify a legacy Delphi 2007 application.
Under certain conditions, I want make sure no record been selected for a table by supply invalid keys before calling the TDataSet.Locate function. The general process is:
User select an item (Key No. 1 for example) in a list from Grid
User do something in other screens (X, Y, Z for example) which all using Key No. 1 to retrieve data in other tables
But on one screen (say it to be screen X), I want the grid forget the
selected item, but should still had the list and data, just nothing been selected again. and all other screen should not load any data unless the user starting from step 1 again to select an item from the list again.
The current application will always have a item selected without user specifically select anything, which will be the first record in the list, and it will almost certainly never be the right one. It can be slightly improved by make sure the most recently change record been selected by default, which will be right sometimes but not most of the times. I think a better approach would be
ask the user always to select an item in the first screen in the list, and again after they finished screen Z.
So the first thing I tried is to do a locate for invalid index. But of course it doesn't working as Locate will not change the last active record if new Locate failed (find no record). Consequently, there will always an activated record.
My question is, is there any way I can reset/clear out the activate record after there been successful Locate?
I have a Count query that uses multiple criteria to produce a result looking like:
count ID
1 "abc"
4 "bcd"
5 "def"
1 "cde"
This shows how many times the ID appears in a given database. The datasource is through an odbc connection that updates automatically. So the ID values change everytime it is opened. I would like to try to turn the unique ID or the associated count into a hyperlink that when clicked will return all information involved in the count (*note the database has much more information associated with the ID's than is counted, a date range of the previous three months is applied.) Can this be done simply?
Database format:
ID Instance Device DateBeg DateEnd
Thanks in advance,
LP
The short version -
This should be simple to do using a report (but could also be done using a form I will be explaining how to do a report for this version). You would just make a report that includes all of your fields then call the report on click. It is important to mention that you will need to view the query via a form to make this work.
A more detailed version -
The first step will be to make a form based on your query (you will not be able to do this directly from a query). To do this select your query then click on the create tab then click Multiple Items Form. Adjust as needed.
Then create a report that shows ALL of the records how you want it to display. (I will call it rpt_ViewDetails) (we will limit later)
When you are done adjusting click on the field that contains the "abc" etc. results (if this is a calculated field it will be more complicated.) I will call this field "Criteria" for the example. Go to the events tab on the property sheet (in design view). use the On Dbl Click event and go to code builder.
This is what the code would look like (place in between the private sub.... and the end sub lines of code):
DoCmd.OpenReport "frm_ViewDetails", acViewNormal, , "[Criteria] = " & Me.Critera
Let me know if you have any trouble with this, also let me know if the structure is different than I am assuming, I will need a more detailed report of what the query is doing if this is the case, what the structure of the database is etc.
I am working jqgrid pagination .And stucked at a very basic problem but it is really irritating me.
There are two main aspects of what i am doing.
1. Server side pagination for server side data.
2. Client side pagination for server side searching
In 1st case i am fetching 50 records for every pager button(next,previous,last,first) and also if user enter page number then also correct service call is fetching perfect 50 records for me and setting data. Also as per my requirements i want jqgrid to show total records on the server at the bottom-right side of grid even if grid contains only 50 at current and accordingly total pages should get updated. this is also working properly.
Actual conflict is here .If i search with some criteria service will return me whole data for search say 300 records. Now all the 300 records are fetched in single service call. So i want client side pagination for this .I am able set 300 records and page number also but view {} to {} and page number in textbox at the center does not get updated.
Is there any way to reset the value of page textbox and view{} to {} to default value ?
Please help
It seems, that you post wrong values in total, page and records of the server response. I suppose that you switched the values of records and total. The value of total should be the total number of pages in the dataset. The value of records should be the number of rows (records, items) in the dataset. You should either adjust your server code of specify jsonReader which get (calculate) in correct way the data total, page and records from the data returned from the server.
I recommend you to read the answer to understand why jqGrid send to the server additional parameters and why the server require to return total, page and records.
In an SQLite table in my app, I need to have a column with row numbers going 1,2,3,4,5 (or to be able to get a row number for every row). Now I delete rows and add rows all the time, so I cant just put a number every time I add a new row, because when rows are deleted, the numbering will get messed up. So is there a way to get the row number, or create a special column that will act as row numbering? If so, how?
If you want this to be reset every time you add and delete rows, should this really be a column in your table?
For example, if you just want to be able to select the 20th row from the table, you can use the LIMIT and OFFSET clauses of SQL to select a particular row, e.g., to retrieve the 20th row from my news table, I could do:
SELECT * FROM news LIMIT 1 OFFSET 19;
Alternatively, if you really want a column with this row number information, you could just add a new INTEGER column type and then write an Objective C method to update the values for that column, and invoke that method any time you delete or insert rows in your result set.
There are a number of ways of solving your problem. You have to explain what you're trying to accomplish for us to help you out. The typical AUTOINCREMENT answer is what we generally use for table keys, but it sounds like you don't want this to be the key of your table, but rather something else.
If you use ROWID which is an auto-incrementing number, you can compute row numbers by selecting all of your data, ordered by ROWID and then using their index in the returned results as their row number. If you have some data model class you're creating, you could pass that in to its initializer.
If that won't do what you want, then how about adding some more details about what you're trying to do. Are you sure you need a row number?
You don't want to go changing all the existing records in your database when you delete rows that make "holes" in your row-umber scheme.
SQLite already supports what you want, with the ROWID. When you make a select query, just specify it to sort on ROWID, and all your returned records will be sorted in their proper order, and you can iterate over them in their order.
See this page: http://www.sqlite.org/autoinc.html
FWIW, there are certainly places where you should prefer direct SQLite over Core Data. However, those are rare cases. In general, reach for Core Data first, and fall back to SQLite only when CD does not serve your needs.
Just use an autoincrement primary key for the table. then there is always a unique identifier you can access a record.