Merge two tables in HTML and Ninox
Hi there I have to tables for a mail systen in Ninox
One is saving all written ones the other one is saving all incoming emails.
For a better overview I wanted to merge booth tables in a contact section of a client.
The idea is that I can see in this list all incomming and outgoing emails as an overview.
A tried couple of thinks but I am gettin error Messages for email.Datum, email.Betreff and Email.Absender.
As soon as I am removing a table in
let combinedEmails := emailSchreiben + emailVerwaltung;
everything works (of course only with one table). My guess is, that there is a problem with merching the tables. Maybe some of you have an idea?
let emailSchreiben := do as server
(select 'Email Schreiben').{
Datum: 'Datum + Uhrzeit',
Betreff: if Betreff then Betreff else "Kein Betreff" end,
Absender: if Absender.Vorname then Absender.Vorname else "Unbekannt" end,
Status: "<span style='background-color: green; color: white; padding: 5px 10px; border-radius: 5px;'>Gesendet</span>"
}
end;
let emailVerwaltung := do as server
(select 'Email Verwaltung').{
Datum: 'Datum + Uhrzeit',
Betreff: if Betreff then Betreff else "Kein Betreff" end,
Absender: if Absender.Vorname then Absender.Vorname else "Unbekannt" end,
Status: "<span style='background-color: blue; color: white; padding: 5px 10px; border-radius: 5px;'>Empfangen</span>"
}
end;
let combinedEmails := emailSchreiben + emailVerwaltung;
html("
<table style='width: 100%; border-collapse: collapse;'>
<thead>
<tr>
<th style='border: 1px solid #ddd; padding: 8px;'>Datum</th>
<th style='border: 1px solid #ddd; padding: 8px;'>Betreff</th>
<th style='border: 1px solid #ddd; padding: 8px;'>Absender</th>
<th style='border: 1px solid #ddd; padding: 8px;'>Status</th>
</tr>
</thead>
<tbody>" +
for email in combinedEmails do
"<tr>
<td style='border: 1px solid #ddd; padding: 8px;'>" + if email.Datum then text(email.Datum) else "Unbekannt" end + "</td>
<td style='border: 1px solid #ddd; padding: 8px;'>" + email.Betreff + "</td>
<td style='border: 1px solid #ddd; padding: 8px;'>" + email.Absender + "</td>
<td style='border: 1px solid #ddd; padding: 8px; text-align: center;'>" + email.Status + "</td>
</tr>"
end +
"</tbody>
</table>
")
9 replies
-
I think you might need to change:
let combinedEmails := emailSchreiben + emailVerwaltung;
to
let combinedEmails := array(emailSchreiben,emailVerwaltung);
When you create the two JSON variables, you are creating an array of data as well. So to merge two arrays you use the array() command. You can't use the + symbol to merge two arrays.
-
I have one other question.
Finally I added a function customOpenRecords which is showing me the iD and the Table Name from the single records. I double checkt it with an alert. The table name and the ID is right. But however Ninox doesn't open the conected record in a pop Up window when I am clicking on the datas.My guess is, it has something todo that Ninox first has to open the right table and then the record within the table. Maybe you have an idea?
let emailSchreiben := do as server (select 'Email Schreiben').{ ID: number(Nr), Tabelle: "Email Schreiben", Datum: date('Datum + Uhrzeit'), Betreff: if Betreff then Betreff else "Kein Betreff" end, Absender: if Absender.Vorname then Absender.Vorname else "Unbekannt" end, Status: "<span style='background-color: green; color: white; padding: 5px 10px; border-radius: 5px;'>Gesendet</span>" } end; let emailVerwaltung := do as server (select 'Email Verwaltung').{ ID: number(Nr), Tabelle: "Email Verwaltung", Datum: date('Datum + Uhrzeit'), Betreff: if Betreff then Betreff else "Kein Betreff" end, Absender: if Absender.Vorname then Absender.Vorname else "Unbekannt" end, Status: "<span style='background-color: blue; color: white; padding: 5px 10px; border-radius: 5px;'>Empfangen</span>" } end; let combinedEmails := array(emailSchreiben, emailVerwaltung); html(" <style> tr:hover { background-color: #f0f8ff; } </style> <table style='width: 100%; border-collapse: collapse;'> <thead> <tr> <th style='border: 1px solid #ddd; padding: 8px;'>Datum</th> <th style='border: 1px solid #ddd; padding: 8px;'>Betreff</th> <th style='border: 1px solid #ddd; padding: 8px;'>Absender</th> <th style='border: 1px solid #ddd; padding: 8px;'>Status</th> </tr> </thead> <tbody>" + for email in combinedEmails do "<tr class='highlight-row' onclick='customOpenRecord(this)' data-table='" + email.Tabelle + "' data-id='" + email.ID + "' style='cursor: pointer;'> <td style='border: 1px solid #ddd; padding: 8px;'>" + date(email.Datum) + "</td> <td style='border: 1px solid #ddd; padding: 8px;'>" + email.Betreff + "</td> <td style='border: 1px solid #ddd; padding: 8px;'>" + email.Absender + "</td> <td style='border: 1px solid #ddd; padding: 8px; text-align: center;'>" + email.Status + "</td> </tr>" end + "</tbody> </table> <script> function customOpenRecord(row) { // Hole die Tabelle und Datensatz-ID aus den Attributen let tableName = row.getAttribute('data-table'); let recordId = row.getAttribute('data-id'); // Öffne den Datensatz im Popup ui.popupRecord(tableName, recordId); } </script>")
-
its working!!! Thanks so much!
Content aside
- Status Answered
- 2 wk agoLast active
- 9Replies
- 42Views
-
2
Following