Welcome to the Protogrid Developer Wiki. A place to gather all the documentation and tips&tricks regarding Protogrid.

Create Button

This article explains how to add own buttons which create new Cards to an Overview Card (e.g. the Default Card).

First, add the necessary code. To do this, add a new Client Script Library and define a name for the library. Add the following code at the end of the newly created Script Library:

function guid() {
  function s4() {
    return Math.floor((1 + Math.random()) * 0x10000)
      .toString(16)
      .substring(1);
  }
  return s4() + s4() + '-' + s4() + '-' + s4() + '-' +
    s4() + '-' + s4() + s4() + s4();
} 

This code snippet generates a new Card ID. Next you need to add the code which actually creates your Card. For this, you need to know the key of the Proto which you want your card to be based on. Now you can add the following code snippet below the one above, replacing “my_proto_key” with the key of your Proto.

function create_product(){
    window.open("/"+$APP_URL_NAME+"/" + guid() + "?action=open_new_card&proto_key=my_proto_key", "_self");
}

Next, create a new Trigger. The Trigger should have a well-understandable name. As Script Library choose the newly created one and insert the call to the second code-snippet into the field “Triggered Call”:

create_product();

As last step, add a button to the Overview Proto of the card you want the button to be placed on. Select your Trigger and type in a suitable label for the button which describes its action to the user.

That's it, clicking onto this button will immediately create and open a new Card!

Print/export