Reading dataset into a custom app with Javascript
Hello. I created this customer app but no matter what I do I cannot get anything to display. I have a dataset with a few columns and I want to display those column values in the custom app. I know javascript, html, and css, but having a hard time getting anything from the dataset to display. I have included the files I created along with the output image. Any help would be appreciated. Thanks.
Best Answers
-
I can see that there we probably some simple CSS updates between the code, nothing was added that is hiding or modifying the HTML's classes or ids right?
That could make the table not render, because your code is working fine for me.** Was this post helpful? Click π‘/π/π/π below. **
** If it solved your problem. Accept it as a solution! βοΈ **
Or do you need more help? https://calendly.com/matthew-kastner/15-minute-chat
Did I help you out? Feedback is priceless and will help me more than you know.Write a review!0 -
Here's a couple screenshots showing two different ways I'm calling the dataset. Note the difference in function(result) vs handleResult.
** Was this post helpful? Click Agree or Like below. **
** Did this solve your problem? Accept it as a solution! **1 -
Here is a video of me hooking up the code that I sent you:
And I attached an image of where you can find the uploading of a dataset.
Please π‘/π/π/π this post if you read it and found it helpful.
Please accept the answer if it solved your problem.** Was this post helpful? Click π‘/π/π/π below. **
** If it solved your problem. Accept it as a solution! βοΈ **
Or do you need more help? https://calendly.com/matthew-kastner/15-minute-chat
Did I help you out? Feedback is priceless and will help me more than you know.Write a review!1
Answers
-
Is there a reason you are waiting for the DOMContentLoaded message?
You shouldn't need to wait for that to be fired off.
The below code will now call to a listed dataset:
βββvar domo = window.domo;
var datasets = window.datasets;
// Fetch the data using the pre-configured dataset alias 'DATASET0'
var query = `/data/v1/${datasets[0]}`;
domo
.get(query)
.then(function (data) {
var tableBody = document.getElementById('dataRows');
data.forEach(function(row) {
var tr = document.createElement('tr');
var td1 = document.createElement('td');
var link = document.createElement('a');
link.href = row.URL || '#'; // Adjust the property name as per your dataset columns
link.textContent = row.Title || 'No Title'; // Adjust the property name as per your dataset columns
td1.appendChild(link);
tr.appendChild(td1);
var td2 = document.createElement('td');
td2.textContent = row.Desc || 'No Description'; // Adjust the property name as per your dataset columns
tr.appendChild(td2);
tableBody.appendChild(tr);
});
})
.catch(function (error) {
console.error("Error fetching data:", error);
});** Was this post helpful? Click π‘/π/π/π below. **
** If it solved your problem. Accept it as a solution! βοΈ **
Or do you need more help? https://calendly.com/matthew-kastner/15-minute-chat
Did I help you out? Feedback is priceless and will help me more than you know.Write a review!0 -
Thank you for that. But still not getting any output
0 -
Is there a security setting that I need to update in Domo to make this work?
0 -
I can see that there we probably some simple CSS updates between the code, nothing was added that is hiding or modifying the HTML's classes or ids right?
That could make the table not render, because your code is working fine for me.** Was this post helpful? Click π‘/π/π/π below. **
** If it solved your problem. Accept it as a solution! βοΈ **
Or do you need more help? https://calendly.com/matthew-kastner/15-minute-chat
Did I help you out? Feedback is priceless and will help me more than you know.Write a review!0 -
I got it to work! But I keep getting an error while saving it "Error Creating DomoApp". I suspect that the DATASET0 is not binded correctly to the data. I have to manually select the data every time I access the page.
0 -
here is what I see when I first get into the app. I have to manually choose and bind the data for it to work. Where do I setup the dataset0 to bind with the data?
0 -
Are you saving after you select the dataset at dataset0? It looks like you are calling the dataset properly. And you've selected it. What is the warning in the triangle?
** Was this post helpful? Click Agree or Like below. **
** Did this solve your problem? Accept it as a solution! **0 -
Here's a couple screenshots showing two different ways I'm calling the dataset. Note the difference in function(result) vs handleResult.
** Was this post helpful? Click Agree or Like below. **
** Did this solve your problem? Accept it as a solution! **1 -
//This code uses the example datasetβ¦
var domo = window.domo; var datasets = window.datasets; // get the data domo.get(`data/v1/${datasets[0]}`).then(function(result){ var tableHTML = "<table><tr>"; // Extract headers and make them bold var headers = Object.keys(result[0]); headers.forEach(function(header) { tableHTML += "<th><b>" + header + "</b></th>"; }); tableHTML += "</tr>"; // Loop through each row and populate table result.forEach(function(row) { tableHTML += "<tr>"; headers.forEach(function(header) { tableHTML += "<td>" + row[header] + "</td>"; }); tableHTML += "</tr>"; }); tableHTML += "</table>"; // Link to html document.getElementById("result").innerHTML = tableHTML; });
<!DOCTYPE html> <html lang="en"> <body> <header> <h1>Full Dataset Test</h1> </header> <main> <div id="result"></div> </main> </body> </html>
table { border-collapse: collapse; width: 100%; } th, td { border: 1px solid black; padding: 8px; text-align: left; } th { background-color: #4CABC5; color: white; font-weight: bold; } td:nth-child(3) { border-left: 3px solid black; border-right: 3px solid black; background-color: #A3D4E1; }** Was this post helpful? Click Agree or Like below. **
** Did this solve your problem? Accept it as a solution! **0 -
Here is a video of me hooking up the code that I sent you:
And I attached an image of where you can find the uploading of a dataset.
Please π‘/π/π/π this post if you read it and found it helpful.
Please accept the answer if it solved your problem.** Was this post helpful? Click π‘/π/π/π below. **
** If it solved your problem. Accept it as a solution! βοΈ **
Or do you need more help? https://calendly.com/matthew-kastner/15-minute-chat
Did I help you out? Feedback is priceless and will help me more than you know.Write a review!1
Categories
- All Categories
- 1.8K Product Ideas
- 1.8K Ideas Exchange
- 1.6K Connect
- 1.2K Connectors
- 300 Workbench
- 6 Cloud Amplifier
- 9 Federated
- 2.9K Transform
- 102 SQL DataFlows
- 626 Datasets
- 2.2K Magic ETL
- 3.9K Visualize
- 2.5K Charting
- 754 Beast Mode
- 61 App Studio
- 41 Variables
- 693 Automate
- 178 Apps
- 456 APIs & Domo Developer
- 49 Workflows
- 10 DomoAI
- 38 Predict
- 16 Jupyter Workspaces
- 22 R & Python Tiles
- 398 Distribute
- 115 Domo Everywhere
- 276 Scheduled Reports
- 7 Software Integrations
- 130 Manage
- 127 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 11 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 110 Community Announcements
- 4.8K Archive