Get started

3.2.3 Add a button to table view

Since version 2019/11 you will be able to add buttons executing custom code to every row in table view.

  1. Create an empty file TABLENAME-tv.js in your hooks-folder
    Replace TABLENAME by the exact name of your table.
    If your table is patients, the filename has to be patients-tv.js.
    Pay attention to the uppercase and lowercase letters.
  2. Insert the following code
  3. Save the file and
  4. Reload the table view in the browser
jQuery(function () {
  let tv = AppGiniHelper.TV;
  let tablename = tv.getTableName();
  let href = tablename + "_view.php?SelectedID=%ID%";
  tv.addLink(href, "search", "Open");
});

File: hooks/TABLENAME-tv.js

You will see the new button next to the default checkbox. On click the related detail view opens up.

Please note that we are using the placeholder %ID% in our link which will be replaced by the record's primary key at runtime.

4. Next steps

5. Troubleshooting

If this is not working as expected, check the Troubleshooting guide:

Do you like it?