Skip to main content
Topic: Edit button for custom views (Read 1680 times) previous topic - next topic

Edit button for custom views

Hi,
I created two tables with "users" and "cars". After the login every user should only see his own cars. So I created a custom view with a SQL querry, where every user can see his own car (with the ".USER_ID." helper). This works so far but I would like him to be able to edit the listed cars.
If I log in as an admin and go to the cars/list page I have 3 buttons for each car (edit, view, delete). On my custom view I don't have these options. On List Page Properties I also don't have the option ViewButton, EditButton or DeleteButton.
If I create a normal Database View, then under List Page Properties I am able to enable the Buttons but neither does the page show the buttons nor can I use the ".USER_ID." helper. Any suggestions?

Re: Edit button for custom views

Reply #1
@IanIous‍ please note that custom view does not support the view, edit, or delete page. if you want that, please create a new list page or duplicate a list page in a Database Table and use the where clause in the list page Properties to limit the record to be displayed for the user.

Re: Edit button for custom views

Reply #2
Ok. Is there a way I can put in a custom SQL? For my custom view I have the following SQL Querry
Code: [Select]
SELECT c.id, c.name, c.location, u.first_name
FROM cars AS c
INNER JOIN car_access as ca
ON c.id = ca.car_id
INNER JOIN users AS u
ON ca.user_id = u.id
WHERE u.id=".USER_ID." AND (ca.access_id = 1 OR ca.access_id = 2 OR ca.access_id = 3)

So I am joining 3 tables.

Re: Edit button for custom views

Reply #3
In the new list page I can only join two tabler correct?

Re: Edit button for custom views

Reply #4
@IanIous‍ please look at the ListPage Properties and configure it to your liken. There is a join, having, where, etc. configurations for you to archive what you have n your query, thanks. Here is the documentation https://docs.radsystems.io/phprad-pages/pages/page-properties/list-page-properties#02-default-query-configuration for what you are looking for.

 

Re: Edit button for custom views

Reply #5
@willvin works. Thank you!