I have 2 complex scenarios with regards to my Datagrid. Before I give my scenarios, I give the details.
I have 3 collection Datasources.
Authors : Name, Book (Association), revisionTime
Books : Title, Start Date, End Date, Author (Association)
Years : Start Date, End Date, Year Number.
I have created a datagrid for Authors (Collection Datasource). Lets say authorsGrid
Years can be created and edited on another screen.
Books can be created and edit on another screen.
Scenario 1:
I would like to generate columns on authorsGrid based on Entity (Years) not based on property.
Usually when we generate a column, we use
Datagrid.addGeneratedColumn("propertyname", new DataGrid.ColumnGenerator<Authors, Component>)
But I want to generate columns based on Years entity. I would like to map years to columnid(string) of each generated column.
If there are 4 years. Lets say, 2016, 2017, 2018 and 2019. I want 4 columns to be generated for each year and I want each each to be mapped to columnId.
Is there a way to use (Map<String, Years>) while generating a column for an entity?
If there is a mapping I can collect books written by author in a particular year and store that detail in the cell belonging to the columnid.
Scenario 2:
Authors datasource has a new attribute : revisionTime. Based on revisionTime, the books belonging to Author needs to be checked.
For Example:
Lets say 2 Authors.
Author 1 wrote a book on 2016. RevisionTime : 24 months
Author 2 wrote a book on 2017. RevisionTime : 12 months
AuthorsGrid is displayed with Author Name, revisionTime and 4 generatedcolumn by Years (2016, 2017, 2018 and 2019)
Author 1 row should display “green” on cell belonging to columnId (2016) and should also display “red” on columnId (2018) stating that a revision needs to be made on 2018.
Author 2 row should display “green” on cell belonging to columnId (2017) and should also display “red” on columnIds (2018, 2019) stating that a revision needs to be made on 2018 and 2019.
How to do the calculation to achieve on the authorsGrid? Sometime revisionTime can be 4, 18, 20 months.
P.S: The authorsGrid access and manipulation is for the administrator who can view, check and apply revision to books belonging to authors.
Your suggestions to both the scenario with be helpful. Thank You.