I have a table working now both with a Vue based UIbuilder version and a jquery UIbuilder version (I figured I better get both working to figure out what I prefer). I'll post the code to get your feedback or maybe help others. It's nothing special, but at least it's another example.
Before I do so, I have a couple questions so maybe I can make a couple tweaks:
Taking @bakman2 suggestion, I flattened my object to an array of objects.
{
"devices": [
{
"serial": "1a",
"channel": 0,
"status": "running",
"value": 100,
"setpoint": 200
},
{
"serial": "1a",
"channel": 1,
"status": "running",
"value": 100,
"setpoint": 200
}
]
}
This made creating a table much easier, but is there really no downside to this format versus my original object:
{ "serialNum": {
"1a": {
"channel": {
"0": {
"status": "running",
"value" : 100.0,
"setpoint": 200.0
},
"1": {
"status": "running",
"value" : 100.1,
"setpoint": 200.1
}
}
},
"2a": {
"channel": {
"0": {
"status": "running",
"value" : 200.0,
"setpoint": 300.0
},
"1": {
"status": "running",
"value" : 200.1,
"setpoint": 300.1
}
}
},
"3a": {
"channel": {
"0": {
"status": "stopped",
"value" : 300.0,
"setpoint": 400.0
},
"1": {
"status": "stopped",
"value" : 300.1,
"setpoint": 400.1
}
}
}
}
}
Maybe I do not understand objects like I thought I did. I would have guessed my original object would be desirable because I could quickly drill down to a value of a specific channel on a specific board. For example the program would just quickly skip over all the objects that do not match the desired serial number. In the new object the program has to potentially loop through every single object in the array to find what I am looking for. For making a table, especially a sortable table, I suppose it does not matter because every row is basically an object. Maybe it just depends on the final use case how to structure the object.
My other questions relate to Vue:
-
Should there only be a single
var app1 = new Vue({ // The HTML element to attach to el: '#app',
Or might there be a case for multiple of these? I ask because it seems my entire html<body>
will be encased in<div id="app">
-
In looking at @TotallyInformation complex home dashboard Vue app I see there are many Vue components. Even though they are outside of the initialized
new Vue()
Are those able to make use of the msg object because they sharedtOpts
like this?
data: function() { return {
// For formatting dates and times
dtOpts: {
timeZone: 'Europe/London',
weekday: 'short', month: 'short', day: 'numeric',
hour: 'numeric', minute: 'numeric',
},
Thanks for the help, I think I am close to understanding the setup and can now just have fun building what I want.