ISchwarz23 / SortableTableView

An Android library containing a simple TableView and an advanced SortableTableView providing a lot of customisation possibilities to fit all needs.
Apache License 2.0
1.05k stars 238 forks source link

Load Dynamic Data #172

Open saravananraj21 opened 5 years ago

saravananraj21 commented 5 years ago

Hi! I need to load dynamic data from database. How to do that ? I want to reduce the text size of headers and table view. Can you help me regarding this.

ISchwarz23 commented 5 years ago

Hi @saravananraj21, You can add the data to your TableDataAdapter and then trigger a new rendering by calling the notifyDataChanged() method. If you want to enable the user to trigger a refresh (pull to refresh) you could use the pro version. You can test the feature in the Example App in the section "Load Data". For setting the text size I need to know which TableDataAdapter you are using. If you are using the SimpleTableDataAdapter and SimpleTableHeaderAdapter you can use the setTextSize() method.

saravananraj21 commented 5 years ago

Hi @ISchwarz23. I have used SortableTableView and loaded the data using SimpleTableDataAdapter . Can you help me how to sort the table and any sample code for that!

ISchwarz23 commented 5 years ago

To make the SortableTableView SortableTableView, you have to set a comparator for each column that should be sortable, by using the SortableTableView#setColumnComparator() method. You can find the code of the example app here. But in this example I used domain objects as table data and not string arrays.

saravananraj21 commented 5 years ago

In my case I don't know how many columns and rows of data will be there.I have to set everything dynamically.Is it possible to do that?

saravananraj21 commented 5 years ago

Hi @ISchwarz23 How to change the text size? I am using SimpleTableDataAdapter and tried to change the size using setTextsize() method but getting error! Please share a sample code.

ISchwarz23 commented 5 years ago

Hi @saravananraj21, There is not much that can go wrong when setting the text size. Check the API here. If the error remains, post the error here.

saravananraj21 commented 5 years ago

Hi @ISchwarz23 I am getting error when calling the setTextsize(). error

error1

Can you help me regarding this issue!

ISchwarz23 commented 5 years ago

Hi,

this is notan TableView issue. The setTextSize() method returns void. This is why you get this "error". To resolve it, just change your code like this:

SimpleTableDataAdapter dataAdapter = new SimpleTableDataAdapter(getActivity(), lstrarr_data);
dataAdapter.setTextSize(10);
dynamic_grid(lint_i).setDataAdapter(dataAdapter);
saravananraj21 commented 5 years ago

Hi @ISchwarz23 Thanks! It worked!

In my case I don't know how many columns and rows of data will be there.I have to set everything dynamically.Is it possible to do that?

Is there any solution for the above?

ISchwarz23 commented 5 years ago

You can add the data to your TableDataAdapter and then trigger a new rendering by calling the notifyDataChanged() method. To change the number of columns use the TableColumnModel (like TableColumnWeightModel) and set the number of columns you need using the setColumnCount( int ) method.

saravananraj21 commented 5 years ago

Hi @ISchwarz23 I have a json array of data to form the table.I need the data to be arranged in the table and the table must be sortable. How can I achieve this using SortableTableView?

ISchwarz23 commented 5 years ago

Please read the section about showing custom data and showing sortable data.