Add a table using your app’s Text fields

A table

 

Podio Calculation field makes use of Markdown features, so we are free to use them.

One of those features is to add a table: Let’s include a table with 3 columns and just 5 rows.

Just copy paste the following code to a Calculation field:

 

/* REPLACE ARRAY ITEMS WITH WHAT YOU WANT!
   YOU CAN ADD AS MANY ITEMS AS YOU WANT! */

var firstLine = [1, 2, 3];
var seconLine = [4, 5, 6];
var thirdLine = [7, 8, 9];
var fourtLine = [10, 11, 12];
var fifthLine = [13, 14, 15];

var start = “”;
var l = “\n:— | :— | :—\n”; 
var i = 0;

for(; i < firstLine.length; i++){
    start = start.concat(firstLine[i]);
    start = start.concat(” | “);
}
for(start += “\n”; i > 0; i –){
    start = start.concat(“:—|”);
}
for(start += “\n”; i < firstLine.length; i++){
    start = start.concat(seconLine[i]);
    start = start.concat(” | “);
}

if(thirdLine.length != 0){
    for(start += “\n”, i = 0; i < firstLine.length; i++){
        start = start.concat(thirdLine[i]);
        start = start.concat(” | “);
}   }
if(fourtLine.length != 0){
    for(start += “\n”, i = 0; i < firstLine.length; i++){
        start = start.concat(fourtLine[i]);
        start = start.concat(” | “);
}   }
if(fifthLine.length != 0){
    for(start += “\n”, i = 0; i < firstLine.length; i++){
        start = start.concat(fifthLine[i]);
        start = start.concat(” | “);
}   }
start

/* This is a comment line so that calc field works @Text 
   I have just added a Podio field of this app*/ 

/* ——————————————————————————————————-

Created by BendixKiel ApS – Copenhagen based Podio Preferred Partner -with more than 6 years of experience in helping organizations implement Podio. Please feel free to contact us if you need help evaluate, structure or implement Podio in your organization.

BendixKiel ApS www.bendixkiel.org +45 71 99 05 80 anders@bendixkiel.org

———————————————————————————————————– */

And replace the @Text with any text field of your app. We just include a redundant @Text, in order to make calc field work.

What is happening here? Don’t get confused with all that code! We are just going to change “firstLine”, “secondLine”, etc.

As you can see, there are numbers from 1 to 15. By replacing those numbers with Podio feeds, and with text in ” “, we can create a table!

Let’s use three Text fields of our app as column names. Replace the numbers of firstLine with the columns names and add “” as the first element. The numbers of seconLine and thirdLine will be replaced with text written in ” “. Last we erase all numbers from fourtLine and fifthLine, we don’t want those table line to contain anything.

 

Thus, the following changes in “Modify Template”:

markdown9.1

Notice the use of text fields in the code in this example

 

give us the following result

A table

A table

2 Responses to Add a table using your app’s Text fields

  1. tim October 17, 2016 at 7:06 pm #

    I can’t get your code to work. Would be grateful for your thoughts….

    /* @[Unique ID] */

    var firstLine = [text, text, text];
    var secondLine = [text1, text2, text3];
    var start = “”;
    var l = “\n:— | :— | :—\n”;
    var i = 0;
    for(; i 0; i –){
    start = start.concat(“:—|”);
    }
    for(start += “\n”; i < firstLine.length; i++){
    start = start.concat(secondLine[i]);
    start = start.concat(" | ");
    } }
    start

    • Lilia Amundsen October 18, 2016 at 5:36 pm #

      Hi Tim, part of the reason the ode doesn’t work is that there is a formating error when coping code from external sites to Podio, so I have sent you an email with a code snippet that should work. Please let me know if this did not reach you at lilia@smartgantt.com.

      Best regards, Lilia

Leave a Reply