Is possible populate a grid with List of objects?

Hi All
I would like to populate a Timesheet grid with a complex query.
Is possible populate this ActionView with the returned Timesheet List

ActionViewBuilder actionView =
ActionView.define(I18n.get(“Employees Timesheet Status”))
.model(Timesheet.class.getName())
.add(“grid”, “employees-timesheet-status-grid”)
.add(“form”, “employee-timesheet-status-form”);

Then specify data list to render?

Thanks

in my view or knowledge is only the custom view can be rendered with custom query, rest someone from axelor team can better comment

2 « J'aime »

Thanks @siddique
I did a custom view! However I was also looking for a different way to to it!

1 « J'aime »

Hello,

In java controller, you can define the domain (filter) to apply on the grid view (possible to build a complex query condition in java). Better to build a filter with some conditions instead of return a list of id. If you return a list of id, if you refresh the grid, the controller is not called and the results will not update.

Hello @gdu-axelor
Thanks for clarification, I was trying to use domain and filtering

However this is my query

SELECT au.name,
CASE
WHEN ht.status_select=1 THEN ‘Draft’
WHEN ht.status_select=2 THEN ‘Waiting Validation’
WHEN ht.status_select=3 THEN ‘Validated’
WHEN ht.status_select=3 THEN ‘Refused’
END AS status_select,
ht.from_date, ht.to_date
FROM hr_employee he
INNER JOIN auth_user au ON au.employee = he.id
LEFT JOIN hr_timesheet ht ON au.id = ht.user_id
WHERE he.manager_user = :userId AND (current_date >= ht.from_date AND current_date <= ht.to_date)
AND ht.status_select < 5
union
SELECT au2.name, null, null, null
FROM hr_employee he2
INNER JOIN auth_user au2 ON au2.employee = he2.id
WHERE he2.manager_user = :userId AND au2.id not in (
SELECT au3.id
FROM hr_employee he3
INNER JOIN auth_user au3 ON au3.employee = he3.id
LEFT JOIN hr_timesheet ht2 ON au3.id = ht2.user_id
WHERE he3.manager_user = :userId AND (current_date >= ht2.from_date AND current_date <= ht2.to_date)
AND ht2.status_select < 5
)
ORDER BY name;

If possible could you post and example how you use domain filtering with a complex query.

Regards
Fabio