need help working with grid

     public class DataOfWeather {
    private List<Main> main = new ArrayList<>();

    private List<TimeModel> timemodel = new ArrayList<>();

// getters and setters…

 public class Main {

    private double temp;

    private double tempMin;

    private double tempMax;
	//getters and setters
	public class MyUI() extends UI{
	        WeatherService weatherService = new WeatherService();
    Grid<DataOfWeather > grid = new Grid<>();

    DataOfWeather weatherList = weatherService.getResponse(url);

how to set to the grid all list from DataOfWeather.class Weather & Main?

bu how to put all list like that → getMain().getTemp() ?

You need to provide a function that is called with an instance of DataOfWeather and returns your temp from Main.
grid.addColumn( x → getMain().getTemp() ); should do.

Note that this is potentially a bad design and you probably want to have the temperatures within your DataOfWeather class.

            grid.addColumn(x-> x.getMain().get(0).getTemp());

yes like that just i can get one index… but how to get all of them?

Do you have a known number of Main items in each DataOfWeather? Then just create a for loop and add a column for each with index. So

for (int i = 0; i < NUMBER_OF_MAINS; i++) {
  grid.addColumn(x-> x.getMain().get(i).getTemp());

its not simple like look on first time…that one im already try like week ago, but where “get(i)”,
that error becouse (i) “Error:(66, 49) java: local variables referenced from a lambda expression must be final or effectively final”… and that not make any sens if i do like that

  grid.addColumn(x-> x.getMain().get(i).getTemp()).setCaption("temp");

You can probably work it around by introducing local final variable, like that:

for (int i = 0; i < NUMBER_OF_MAINS; i++) {
  final int tempI = i;
  grid.addColumn(x-> x.getMain().get(tempI).getTemp());

not really like that make rows, but not columns :frowning:

If by columns you mean the values going vertically from top to bottom, then those values are in fact called rows :wink: Correct me if I misunderstood you.

i need column :slight_smile:

Ok, now, after I read your original message, I got what you mean. :slight_smile:

I think the easiest solution would be to create a list of DTOs from DataOfWeather you received from WeatherService and use it in setItems.

any example please?