Created New Data Structure Now Can't Populate Table
Created New Data Structure Now Can't Populate Table
zgoforth
Posts: 493Questions: 98Answers: 2
Link to test case: https://jsfiddle.net/BeerusDev/drufevb8/2/ here is the logic I used to transform the data structure.
Here is how the data is shown when I console log it:
{
"Department": "IT",
"Employee": "Shap Dev",
"Days": [
{
"Day": "Monday",
"Date": "6/28/2021",
"Status": "P",
"Location": "Office"
},
{
"Day": "Tuesday",
"Date": "6/29/2021",
"Status": "P",
"Location": "Office"
},
{
"Day": "Wednesday",
"Date": "6/30/2021",
"Status": "P",
"Location": "Office"
},
{
"Day": "Thursday",
"Date": "7/1/2021",
"Status": "P",
"Location": "Office"
},
{
"Day": "Friday",
"Date": "7/2/2021",
"Status": "P",
"Location": "Office"
}
]
};
I am trying to populate the Monday and Monday Status (followed by every other corresponding day and status), but I keep getting an alert that I am trying to access an unknown parameter?
Answers
Your test case doesn't run.
You have
"data": "Days.Day[0]"
. Your array isDays
so you need to do something more like this"data": "Days.0.Day"
.Kevin
The other issue that I am having with it as well is trying to apply the data to a tooltip over the cell with the columnDefs option:
The table populates fine until I try to add to this :
If you want help with this please provide a running test case showing the issue. You can add the above example data like this:
http://live.datatables.net/sasitavu/1/edit
You can update this example to show the issue.
Kevin
Here is the updated example: http://live.datatables.net/sasitavu/2/edit
The Location in the tooltip is
undefined
becuase you don't havefull.MondayLocation
in your data structure. Same withmoment(full.Monday)
. You need to reference them from the array, like this example for Monday:http://live.datatables.net/dafanuze/1/edit
Kevin
Thank you! I was close but not close enough! One last thing that is really preventing me from getting back to where I was on my original example in my other post, is with this new data structure, I cannot figure out the issue with my object look ups in my rows.every() function: It tells me that
jQuery.Deferred exception: Cannot convert undefined or null to object", "TypeError: Cannot convert undefined or null to object
Here is my most recent test case: https://jsfiddle.net/BeerusDev/exzqys93/7/
I don't see the error message in your test case. Try searching Stack Overflow for the error to find suggestions of what the problem might be.
Kevin
It is because I commented that line out, it messes up the table if I leave it uncommented, and I will try I unfortunately got downvote bombed and have to wait 5 1/2 months to be able to ask one more question (super aggravating)… now it is just returning undefined and n/a. I think I need to reference transformedResults instead of Data but thats where the issues come into play: https://jsfiddle.net/BeerusDev/exzqys93/11/
Lines 265-275
Its hard to keep track of what you are trying to do with your solution. I guess this is the statement that is not working the way you want:
Start by debugging
data
to see what the structure is. Then adjustObject.keys(data)
to access the portion ofdata
you are interested in. And changetypeof data[key]
to match.Kevin
https://jsfiddle.net/BeerusDev/exzqys93/45/
I have tried a new method of going about this as recommended by someone else using a class function instead of a counter function, and when I insert it, it screws up all of the brackets even though they are matching?
Look at the browser's console. You are getting this error:
This forum is for helping with Datatables issues. Please limit your questions to Datatables issues. General Javascript coding and debugging is not appropriate for this forum.
Kevin