Filling a Datagrid with two entities

Hi, It will be possible to fill a datagrid with the records of two entities using a date range filter applied to a date field in both entities?
Thanks.

Hello Jorge,

Could you please explain in more details what you want to achieve? Are these entities should be displayed in the same row or you want to group entities like in GroupTable.

Regards,

Gleb

Hi Gleb, first, I would like to fill the datagrid with an entity query and after the last row with the other entity query, and if it is possible to sort the datagrid with a date field (column). I would like to mix two entities in one datagrid, but, sorted with a date column.

Thanks.

Regards.

Jorge

Hi,

does that mean that both of your entities have the same attributes?

You probably create a view in the db that does a union on two tables and create an entity that matches the column’s of the view.

Can you share an example project?

Bye
Mario

Hi, actually I have a VB6 desktop app with a mysql table with two kinds of users, “WEB” and the user’s id, using the field “Usuario”. Into a grid I can do queries and sorted leaving the “WEB” users to the end, but, I need to separate this table in two tables, because I need to add a primary key to the table with the field named “Folio”, but, in order to do this I need to extract the records with “WEB” users because these have value 0 in the field “Folio”, then when I want to create the primary key is not allowed because the value 0 is repeated. Below there’s an image of the grid.

Regards.

grid

Hi,

this sounds like you should have inheritance for the entities in place. You might want to have a look at this explanation.

I assume from your description that a inheritance might look like this, correct?

You should try to create an example project in order to better help you.

Bye
Mario

46b6e66a

Hi,

I’ve prepared the simple project based on this sample. I’ve added browse screen for the base entity (Customer) in which I use DataGrid with generated column to show customer type (Person or Company).


customersDataGrid.addGeneratedColumn("customerType", new DataGrid.ColumnGenerator<Customer, String>() {
	@Override
	public String getValue(DataGrid.ColumnGeneratorEvent<Customer> event) {
		if (event.getItem() instanceof Person) {
			return "P";
		} else if (event.getItem() instanceof Company) {
			return "C";
		} else {
			return null;
		}
	}

	@Override
	public Class<String> getType() {
		return String.class;
	}
});

I think this may be the start point for you.

Regards,

Gleb

entity-inheritance.zip (112.7K)

Hi, I put a diagram below with the two possible enitities, and fill the grid with these ones based on a date range.

Thanks

Regards.

diagram