Add Button (Table View)

// file: hooks/patients-tv.js

jQuery(function () {
  var tv = new AppGiniTableView();
  tv.addButton(function (id) 
  {
    alert("User clicked #" + id);
  }, "flash", "My function"); 
  // "flash" is the name of the glyphicon
  // "My function" is the button text

});

Tipp
Instead of executing Javascript function you can also add links. See here.

Syntax

new AppGiniTableView().addButton(callback, icon, text, variation);

Parameters

  • callback
    javascript function with id-parameter, eg function (id) { /* your code here */ }
  • icon
    optional, string, eg. "cog", see also Glypgicons
  • text
    optional, string, Button Text, eg. "Open"
  • variation
    optional, Variation, e.g. Variation.danger

Please note

The .addLink() method (see here) has a prompt parameter which, if set, automatically displays a confirmation prompt.

This .addButton() method does not have a prompt parameter. But you can show the alert or confirmation prompt in your code - if required.

  • Add button named "My function"
    with icon "glyphicon-flash"
  • On click
    • get last name
    • get first name
    • concatenate a text
    • show alert
// file: hooks/patients-tv.js
jQuery(function () {

  var tv = new AppGiniTableView();
  tv.addButton(function (id) {

    var last_name = tv.getValue(id, "last_name");
    var first_name = tv.getValue(id, "first_name");
    var text = "Clicked item #" + id + ": " + last_name + ", " + first_name;
    customAlert(text);
  }, "flash", "My function");

});

See also

Do you like it?