Select to view content in your preferred language

How to insert a table in a custom attribute pop-up?

4925
3
Jump to solution
11-02-2016 11:44 AM
DavidSemitekol3
Deactivated User

I am trying to insert a table into the pop-up using the custom attribute display.  When authoring in HTML and in the preview (picture 1) you can see the table, but when I click on a symbol the pop-up does not display the table, just the data (picture 2).  I have also included the beginning of the html code for a sample (picture 3).

Or is there a way to format the text list so that it is properly spaced?

Thanks

1 Solution

Accepted Solutions
MarkHoyland
Frequent Contributor

I could get a table to display in a custom attribute display. 

Here is what I used (based on the table example at Tryit Editor v3.1 )

<style>
#mytable {
  font-family: arial, sans-serif;
  border-collapse: collapse;
  width: 100%;
}

#mytable td, #mytable th {
  border: 1px solid #dddddd;
  text-align: left;
  padding: 8px;
}

#mytable tr:nth-child(even) {
  background-color: #eeeeee;
}

#mytable th {
  font-weight:bold;
}

</style>

<table id="mytable">
<tbody>
  <tr>
    <th>Company</th>
    <th>Contact</th>
    <th>Country</th>
  </tr>
  <tr>
    <td>Alfreds Futterkiste</td>
    <td>Maria Anders</td>
    <td>Germany</td>
  </tr>
  <tr>
    <td>Centro comercial Moctezuma</td>
    <td>Francisco Chang</td>
    <td>Mexico</td>
  </tr>
  <tr>
    <td>Ernst Handel</td>
    <td>Roland Mendel</td>
    <td>Austria</td>
  </tr>
  <tr>
    <td>Island Trading</td>
    <td>Helen Bennett</td>
    <td>UK</td>
  </tr>
  <tr>
    <td>Laughing Bacchus Winecellars</td>
    <td>Yoshi Tannamuri</td>
    <td>Canada</td>
  </tr>
  <tr>
    <td>Magazzini Alimentari Riuniti</td>
    <td>Giovanni Rovelli</td>
    <td>Italy</td>
  </tr>
</tbody></table>

View solution in original post

3 Replies
MarkHoyland
Frequent Contributor

I could get a table to display in a custom attribute display. 

Here is what I used (based on the table example at Tryit Editor v3.1 )

<style>
#mytable {
  font-family: arial, sans-serif;
  border-collapse: collapse;
  width: 100%;
}

#mytable td, #mytable th {
  border: 1px solid #dddddd;
  text-align: left;
  padding: 8px;
}

#mytable tr:nth-child(even) {
  background-color: #eeeeee;
}

#mytable th {
  font-weight:bold;
}

</style>

<table id="mytable">
<tbody>
  <tr>
    <th>Company</th>
    <th>Contact</th>
    <th>Country</th>
  </tr>
  <tr>
    <td>Alfreds Futterkiste</td>
    <td>Maria Anders</td>
    <td>Germany</td>
  </tr>
  <tr>
    <td>Centro comercial Moctezuma</td>
    <td>Francisco Chang</td>
    <td>Mexico</td>
  </tr>
  <tr>
    <td>Ernst Handel</td>
    <td>Roland Mendel</td>
    <td>Austria</td>
  </tr>
  <tr>
    <td>Island Trading</td>
    <td>Helen Bennett</td>
    <td>UK</td>
  </tr>
  <tr>
    <td>Laughing Bacchus Winecellars</td>
    <td>Yoshi Tannamuri</td>
    <td>Canada</td>
  </tr>
  <tr>
    <td>Magazzini Alimentari Riuniti</td>
    <td>Giovanni Rovelli</td>
    <td>Italy</td>
  </tr>
</tbody></table>

DavidSemitekol3
Deactivated User

Thank you for your reply and help.

The code seems to work but then when I try to view the popup in the Web Map Application it bugs out and only shows the text again.

0 Kudos
MarkHoyland
Frequent Contributor

Hmmm...  It works in AGOL map, but when adding a map to an app it strips out the styling block. Two things you could try:

1. Use a plain table without any styling should give a properly spaced result.

2. For a styled table try inline styling for each tag. (pretty messy, and high maintenance if you need to change it, but it seems to work)

eg

<table style="font-family: arial, sans-serif;border-collapse: collapse;text-align: left;">
<tbody>
  <tr>
    <th style="border: 1px solid #ddd;padding: 8px;">Company</th>
    <th style="border: 1px solid #ddd;padding: 8px;">Country</th>
  </tr>
  <tr style="background-color: #eee;">
    <td style="border: 1px solid #ddd;padding: 8px;">Alfreds Futterkiste</td>
    <td style="border: 1px solid #ddd;padding: 8px;">Germany</td>
  </tr>
  <tr>
    <td style="border: 1px solid #ddd;padding: 8px;">Centro comercial Moctezuma</td>
    <td style="border: 1px solid #ddd;padding: 8px;">Mexico</td>
  </tr>
  <tr style="background-color: #eee;">
    <td style="border: 1px solid #ddd;padding: 8px;">Ernst Handel</td>
    <td style="border: 1px solid #ddd;padding: 8px;">Austria</td>
  </tr>
  <tr>
    <td style="border: 1px solid #ddd;padding: 8px;">Island Trading</td>
    <td style="border: 1px solid #ddd;padding: 8px;">UK</td>
  </tr>
  <tr style="background-color: #eee;">
    <td style="border: 1px solid #ddd;padding: 8px;">Laughing Bacchus Winecellars</td>
    <td style="border: 1px solid #ddd;padding: 8px;">Canada</td>
  </tr>
  <tr>
    <td style="border: 1px solid #ddd;padding: 8px;">Magazzini Alimentari Riuniti</td>
    <td style="border: 1px solid #ddd;padding: 8px;">Italy</td>
  </tr>
</tbody></table>