Adding rows in a loop
kevinkhill opened this issue · 2 comments
kevinkhill commented
I have same issue
Cannot display multiple rows using loop using the following code:
$temps = Lava::DataTable();
$temps->addStringColumn('Type')
->addNumberColumn('Temp');
foreach ($sensor_status as $sdata) {
$temps->addRow(['Temp', $sdata->temprature])
->addRow(['Humidity', $sdata->humidity]);
}
Originally posted by @muazzamazaz in #246 (comment)
kevinkhill commented
I'm confused by that snip a little...
It looks like you have a string and number column, but then add two rows per loop?
It should be more like...
$temps = Lava::DataTable();
$temps->addStringColumn('Time')
->addNumberColumn('Temp')
->addNumberColumn('Humidity');
foreach ($sensor_status as $sdata) {
$temps->addRow(["4pm", $sdata->temprature, $sdata->humidity]);
}
kevinkhill commented
Closing due to staleness, please open a fresh issue if you are still having issues