How to create a list with data tables as items - java

What I want is to create a list where each item in that list is an data table like below: http://imgur.com/a/mQdi5 Example data table The user needs to be able to sort items in the data table and needs to be able to sort the data tables itself.
Each table is going to represent a client and each item in that table is an order. The user will then collect the orders, if he collected an order the order wil dissapear but the user is also able to bring them back.
I've tried to put a Recyclerview inside a Recyclerview but this caused unitended side effects and bugs, also I read online that it is basically a bad practice. My initial intention was to use a recylcerview with a sortedlist.
I did some searching online and a lot of people recommended using categories between items so that you only need one list. But because I have data tables (CardViews) that can be independent sorted this isn't an option.
If anyone want to give me a nudge in the right direction, I would be really thankful.

Related

What is the correct way to dynamically change columns and data model in nattable?

When changing the number of columns and rows of natTable
After clearing the column list of DataProvider, create a new column item and change the column item list of columnPropertyAccessor.
Then, put the new data model into the filter list and refresh it.
When the 7-column nattable is sorted (ascending or descending) and clicked, it is changed to a different data model (4 columns) as above, but if it is sorted, "CurrentModificationException" and "IndezxOutOfBoundException" occur.
If you exchange data models without sorting, there is no problem.
I don't know which part is causing it.
Is my way of replacing the filter list wrong when changing the data model?
If anyone has encountered a similar error and has solved it, please help.
Well you don't show how you are doing things, so I can't tell any details. But to answer your question, yes I think you are doing things wrong.
In short, if you have a state applied according to a column like sorting or filtering and you change the underlying data structure, things will break as the states does match the structure anymore. Not sure why you think this should work automatically.
If you change the underlying data structure you need to clear structure based states in advance.
There is an example in the NatTable examples application that shows how to change the data provider dynamically. Not sure if the example covers the clearing of states or if this is handled automatically when you are doing things correctly.

How to change the order of list elements in Firebase Real-time database (android-java)?

I'm using Firebase real-time database for my android app. There is a list that I display in a recycler view. I want the user to have the ability to change the order of the cards in the list.
I thought to create a sort key in each element(object) of the list and fetch data using the sort key. But that's too heavy on larger lists. Is there any simpler solution for this?

Realm: Order of records was changed

I'm trying to develop my Android app with Realm database.
Today I got below problem:
I added a list of records to table and then try to deleted one of them.
after deleting the order of the rest was changed (it's different with the order before deleting).
please see the images below to see detail.
Before deleting
After delete the 3rd item
And the question is: That's is an function or an bug? And how Can I keep the order of record?
I know that I can easy to get the correct order as I want with add a new field as createTime or something like that but I want to find an very simple solution as config something for Realm.
Items in a Realm are not sorted by default, so you should think of any query result as an unordered set unless you explicitly sorted it.
Generally the items will come out in the order you inserted them in, but it is not a guarantee. The underlying reason technical reason is that we compact the data on the disk, so if you delete items in the middle of a list, the last item will be moved to its place.
So the answer is: It is working as intended, and you should use a sorting method if you want your results to be sorted.

How to get the value from Jtable

Currently im doing on a project on ordering system. Let me explain the flow of the system. In ordering class, i have 2 jtable. One of the jtables shows the list of food retrieve from the database. I just have to click on one of the food and press"add", the selected food will transfer to another jtable . After i press"proceed" i will be led to a jtable, to the next jpanel, which consists of the food i have selected. However" i allow one cell to be editable,"quantity" is there any way on how to retrieve the data input by the user and store to database?
Depending on the implementation of the TableModel, you could get the data for an individual row. This would, generally, be the preferred solution, as the data for the row would be encapsulated within a POJO which maintains all the data that you need in a single place that easily manageable.
If you've just dumped a bunch of unassociated properties into the table, you will need to use something like JTable#getValueAt or TableModel#getValueAt
See How to Use Tables for more details

From database to application scope

my question is involving database and application scope. I am currently running an web application that stores user info(for login), item info and purchase info. The way I am currently doing storing the data is by putting them in a List. I am thinking of storing the data to a database (mysql) and replace the lists. In thinking about it, i thought of whether it would make sense to store data in the database, but also store it in the Lists. Basically, i would be adding to the List via the database. Would it make sense to do this?Thanks!
You should not save the entire list into the field but each element in the list should be a separate row in the table. This is object-oriented design and it would be good practice to do so.
To achieve this, you need to have a one-to-many mapping for the user table to the purchase table. One user can make multiple purchases but each purchase can only be tied to one user. Therefore, your purchase table should contain a foreign key which is the ID for your user table.
For example, table A should be the list of all your users. Table B should contain all your purchases. We can see that Doug has made 3 purchases, (PA,WV and DE) while Bob has made 2 purchases (TN and NC).

Categories

Resources