package com.example.application.MyGrid;

import com.example.application.MyBook.MyBook;
import com.vaadin.flow.component.grid.Grid;

import java.util.ArrayList;
import java.util.List;

public class MyGrid {

    private Grid<MyBook> grid = new Grid<>(MyBook.class, false);
    public List<MyBook> list =new ArrayList<>();
    public MyGrid(){

        this.setAllColumns();
    }

    public void setAllColumns(){
        grid.addColumn(MyBook::getAuthor).setHeader("Автор").setAutoWidth(true);
        grid.addColumn(MyBook::getTitle).setHeader("Название").setAutoWidth(true);
        grid.addColumn(MyBook::getAmount).setHeader("Количество").setAutoWidth(true);
        grid.setAllRowsVisible(true);
    }
    public void setEntries() {
        this.grid.setItems(this.list);
    }


    public Grid<MyBook> getGrid() {
        return grid;
    }

}
