How to display column data under a specific column in react bootstrap table - html-table

I am create a React Bootstrap Table using data from an array. There can be 4 or 5 columns depending on the array, 3 or 4 of them with data from the array and I want the final column 'Admin' to always contain 2 button. So in the below example there are 4 players and a time taken from the array, but in the array there are 6 players, so the first row is full, and the second row only has 2 players. This is what I am currently getting
Time | player1 | player 2 | player 3 | player4 | Admin
_____________________________________________________________________________________
10:00 | Joe B | Mike A | John S | Paul W | button 1, button 2
______________________________________________________________________________________
10:10 | Karl A | Sean F | button 1, button 2 | |
I want the 2 buttons to always be in the Admin column, even if other columns are not populated.
Time | player1 | player 2 | player 3 | player4 | Admin
_____________________________________________________________________________________
10:00 | Joe B | Mike A | John S | Paul W | button 1, button 2
______________________________________________________________________________________
10:10 | Karl A | Sean F | | | button 1, button 2
Code for the tables,
<Table striped bordered hover responsive>
<thead>
<tr>
<th >Tee time</th>
<th >Player 1</th>
<th>Player 2</th>
<th>Player 3</th>
{teeTimes[0] !== undefined && teeTimes[0].noOfSlots === 4 &&
<th>Player 4</th>}
{props.loggedInUser.role === 'ADMIN' &&
<th id='admin'>Admin</th>}
</tr>
</thead>
{teeTimes.map((teetime =>
<tbody key={teetime.id}>
<tr>
<td>{teetime.teeTime}</td>
{teetime.entrants.map((entrant) =>
<td>{entrant.member['firstName']} {entrant.member['surname']} ({entrant.member['handicap']})</td>
)}
{props.loggedInUser.role === 'ADMIN' &&
<td headers='admin'>
<button className="btn btn-danger m-2" onClick={() => deleteTeeSheet(teetime.id)}>delete</button>
<button className="btn btn-warning m-2" onClick={() => handleShowEditTeeTime(teetime.id)}>Update</button>
</td>}
</tr>
</tbody>
))}
</Table>
Is there a way to tell the table that the buttons <td> should always be under the admin <th>

Related

HtmlAgilityPack Scrape table from website

I am learning how to use HtmlAgilityPack and I cannot find any documentation on scraping tables in the way I need.
My table looks like this
| | NAME | PRICE | TIME |
| --- | ------------------------------------- | ---------------- | --------- |
| | Arma 3 | $29.99 | 1586h 57m |
| | DayZ | $44.99 | 28h 05m |
| | Survarium | Free or No Price | 02h 25m |
| | Squad | $49.99 | 11h 05m |
| | Squad - Public Testing | Not in store | 0h 0m |
| | Counter-Strike: Global Offensive | Free or No Price | 00h 26m |
| | Infestation: Survivor Stories Classic | Free or No Price | 00h 05m |
| | PLAYERUNKNOWN'S BATTLEGROUNDS | $29.99 | 0h 0m |
I have tried many things found on Google regarding tables and HtmlAgilityPack but none have worked.
I have a listview that I want the data to go into. The only things I want are
gname, gprice, gtime loaded to the listview and remembering that these values change depending on the games listed.
I can't post what I've already tried as there would be to many website posts to go back through and find.
The html for the table on the website is this
<div class="col-12">
<h2>Dan Andrews Steam Profile 8 Games</h2>
<div class="table-responsive">
<table class="table game-table">
<tbody>
<tr>
<th></th>
<th class="gname">NAME</th>
<th style="width:200px">PRICE</th>
<th style="width:200px">TIME</th>
</tr>
<tr>
<td class="gicon"><img src="https://cdn.cloudflare.steamstatic.com/steam/apps/107410/capsule_184x69.jpg" onerror="this.src='/assets/images/applogo.svg'">
</td>
<td class="gname">Arma 3</td>
<td class="gprice">$29.99</td>
<td class="gtime">1586h 57m</td>
</tr>
<tr>
<td class="gicon"><img src="https://cdn.cloudflare.steamstatic.com/steam/apps/221100/capsule_184x69.jpg" onerror="this.src='/assets/images/applogo.svg'">
</td>
<td class="gname">DayZ</td>
<td class="gprice">$44.99</td>
<td class="gtime">28h 05m</td>
</tr>
<tr>
<td class="gicon"><img src="https://cdn.cloudflare.steamstatic.com/steam/apps/355840/capsule_184x69.jpg" onerror="this.src='/assets/images/applogo.svg'">
</td>
<td class="gname">Survarium</td>
<td class="gprice">Free or No Price</td>
<td class="gtime">02h 25m</td>
</tr>
<tr>
<td class="gicon"><img src="https://cdn.cloudflare.steamstatic.com/steam/apps/393380/capsule_184x69.jpg" onerror="this.src='/assets/images/applogo.svg'">
</td>
<td class="gname">Squad</td>
<td class="gprice">$49.99</td>
<td class="gtime">11h 05m</td>
</tr>
<tr>
<td class="gicon"><img src="https://cdn.cloudflare.steamstatic.com/steam/apps/774941/capsule_184x69.jpg" onerror="this.src='/assets/images/applogo.svg'">
</td>
<td class="gname">Squad - Public Testing</td>
<td class="gprice">Not in store</td>
<td class="gtime">0h 0m</td>
</tr>
<tr>
<td class="gicon"><img src="https://cdn.cloudflare.steamstatic.com/steam/apps/730/capsule_184x69.jpg" onerror="this.src='/assets/images/applogo.svg'">
</td>
<td class="gname">Counter-Strike: Global Offensive</td>
<td class="gprice">Free or No Price</td>
<td class="gtime">00h 26m</td>
</tr>
<tr>
<td class="gicon"><img src="https://cdn.cloudflare.steamstatic.com/steam/apps/226700/capsule_184x69.jpg" onerror="this.src='/assets/images/applogo.svg'">
</td>
<td class="gname">Infestation: Survivor Stories Classic</td>
<td class="gprice">Free or No Price</td>
<td class="gtime">00h 05m</td>
</tr>
<tr>
<td class="gicon"><img src="https://cdn.cloudflare.steamstatic.com/steam/apps/578080/capsule_184x69.jpg" onerror="this.src='/assets/images/applogo.svg'">
</td>
<td class="gname">PLAYERUNKNOWN'S BATTLEGROUNDS</td>
<td class="gprice">$29.99</td>
<td class="gtime">0h 0m</td>
</tr>
</tbody>
</table>
</div>
</div>
```
Here is a possible solution in C# (even though the question is tagged with VB.Net). You get a list of Game objects here. And you can then bind these to a ListView or whatever you may need.
public class Game
{
public string Img { get; set; }
public string Name { get; set; }
public double? Price { get; set; }
public string? PriceStatus { get; set; }
public TimeSpan? Time { get; set; }
}
public static void Go()
{
HtmlDocument doc = new HtmlDocument();
doc.LoadHtml(File.ReadAllText(htmlFilePath));
Regex timeRegex = new Regex(#"\b(\d+)h\b\s*\b(\d+)m\b", RegexOptions.Compiled);
Regex priceRegex = new Regex(#"\b\$?(\d+\.\d\d)\b", RegexOptions.Compiled);
List<Game> gamesList =
doc.DocumentNode.SelectNodes("//table[#class='table game-table']/tbody/tr")
.Select(tr => tr.SelectNodes("td")?.ToList())
.Where(tds => tds != null && tds.Any())
.Select(
(tds) =>
{
return
new
{
Img = tds[0].SelectSingleNode("img").Attributes["src"].Value,
Name = tds[1].InnerText,
PriceString = tds[2].InnerText,
PriceMatch = priceRegex.Match(tds[2].InnerText),
TimeString = tds[3].InnerText,
TimeMatch = timeRegex.Match(tds[3].InnerText),
};
})
.Select(
(v) =>
{
Game game =
new Game
{
Img = v.Img,
Name = v.Name,
};
//Set Price
if (v.PriceMatch.Success)
{
game.Price = double.Parse(v.PriceMatch.Groups[1].Value);
game.PriceStatus = "In Store";
}
else
{
game.PriceStatus = v.PriceString;
}
//Set Time
if (v.TimeMatch.Success)
{
int hours = int.Parse(v.TimeMatch.Groups[1].Value);
int minutes = int.Parse(v.TimeMatch.Groups[2].Value);
game.Time = new TimeSpan(hours, minutes, 0);
}
return game;
})
.ToList();
}

Vue warning message

While compiling my vue2 project lot of warning message in my code any way to solve this quickly?
In visual studio code it takes lot of time to show this waning
Suggest me to how solve this using any extension or any formating tool?
warning: Replace `parseFloat(this.expectedcapitalgain·/·1000).toFixed(2)` with `⏎······································parseFloat(⏎········································this.expectedcapitalgain·/·1000⏎······································).toFixed(2)⏎····································` (prettier/prettier) at src/pages/Dashboard/Dashboard2.vue:1214:62:
1212 | <span class="graphtext">
1213 | <i class="fa fa-circle text-warning"></i>
> 1214 | Expected Capital Gain ({{parseFloat(this.expectedcapitalgain / 1000).toFixed(2)}})
| ^
1215 | </span>
1216 | <br />
1217 | <span class="graphtext">
warning: Replace `parseFloat(this.ccashflow·/·1000).toFixed(2)` with `⏎······································parseFloat(this.ccashflow·/·1000).toFixed(⏎········································2⏎······································)⏎····································` (prettier/prettier) at src/pages/Dashboard/Dashboard2.vue:1219:61:
1217 | <span class="graphtext">
1218 | <i class="fa fa-circle text-danger"></i>
> 1219 | Cumulative Cash Flow ({{parseFloat(this.ccashflow / 1000).toFixed(2)}})
| ^
1220 | </span>
1221 | </div>
1222 | </div>
warning: Insert `⏎·······························` (prettier/prettier) at src/pages/Dashboard/Dashboard2.vue:1247:80:
1245 | <div class="md-layout-item">
1246 | <span class="graphtext">
> 1247 | <i class="fa fa-circle text-info"></i> Net Cash Flow
| ^
1248 | <br />
1249 | </span>
1250 | <span class="graphtext">
warning: Insert `⏎·······························` (prettier/prettier) at src/pages/Dashboard/Dashboard2.vue:1251:73:
1249 | </span>
1250 | <span class="graphtext">
> 1251 | <i class="fa fa-circle text-danger"></i> Cumulative Net Cash Flow
| ^
1252 | </span>
1253 | </div>
1254 | </div>
warning: Replace `Graph·Values·Are·In·Thousand·AED` with `⏎························Graph·Values·Are·In·Thousand·AED⏎······················` (prettier/prettier) at src/pages/Dashboard/Dashboard2.vue:1257:49:
1255 | </template>
1256 | </chart-card>
> 1257 | <h6 class="graphtext ral">Graph Values Are In Thousand AED</h6>
| ^
1258 | </div>
1259 | </div>
1260 | </template>
warning: Replace `·class="md-layout-item·md-size-100·md-medium-size-100·md-xsmall-size-100"` with `⏎··············class="md-layout-item·md-size-100·md-medium-size-100·md-xsmall-size-100"⏎············` (prettier/prettier) at src/pages/Dashboard/Dashboard2.vue:1268:17:
1266 | <template slot="tab-pane-3">
1267 | <div class="md-layout md-size-100">
> 1268 | <div class="md-layout-item md-size-100 md-medium-size-100 md-xsmall-size-100">
| ^
1269 | <global-sales-card header-color="green">
1270 | <template slot="content">
1271 | <div class="md-layout">
warning: Replace `·style="font-size:20px;font-weight:bold;color:#3c4858;">Documents` with `⏎························style="font-size:20px;font-weight:bold;color:#3c4858;"⏎······················>⏎························Documents⏎······················` (prettier/prettier) at src/pages/Dashboard/Dashboard2.vue:1273:26:
1271 | <div class="md-layout">
1272 | <div class="md-layout-item md-size-100 md-xsmall-size-100">
> 1273 | <h1 style="font-size:20px;font-weight:bold;color:#3c4858;">Documents</h1>
| ^
1274 | <table style="width:100%;">
1275 | <tr>
1276 | <td>
warning: Replace `Marin·Quays·-·Pro·forma·financials` with `⏎································Marin·Quays·-·Pro·forma·financials⏎······························` (prettier/prettier) at src/pages/Dashboard/Dashboard2.vue:1278:47:
1276 | <td>
1277 | <a href="#">
> 1278 | <li class="ahr">Marin Quays - Pro forma financials</li>
| ^
1279 | </a>
1280 | </td>
1281 | <td>
warning: Replace `HiGuests·short·term·rental·report` with `⏎································HiGuests·short·term·rental·report⏎······························` (prettier/prettier) at src/pages/Dashboard/Dashboard2.vue:1305:47:
1303 | <td>
1304 | <a href="#">
> 1305 | <li class="ahr">HiGuests short term rental report</li>
| ^
1306 | </a>
1307 | </td>
1308 | </tr>
error: 'vueNumeralFilterInstaller' is defined but never used (no-unused-vars) at src/pages/Dashboard/Dashboard2.vue:1426:8:
1424 | import VueEasyLightbox from "vue-easy-lightbox";
1425 | Vue.use(VueEasyLightbox);
> 1426 | import vueNumeralFilterInstaller from "vue-numeral-filter";
| ^
1427 | import { API_KEY } from "./Maps/API_KEY";
1428 | import GoogleMapsLoader from "google-maps";
1429 | GoogleMapsLoader.KEY = API_KEY;
error: 'APIService' is defined but never used (no-unused-vars) at src/pages/Dashboard/Dashboard2.vue:1439:10:
1437 | import GoogleAtmMap from "../../components/GoogleAtmMap";
1438 | import GoogleGymMap from "../../components/GoogleGymMap";
> 1439 | import { APIService } from "../../apiservice.js";
| ^
1440 | import {
1441 | StatsCard,
1442 | ChartCard,
2 errors and 247 warnings found.
247 warnings potentially fixable with the `--fix` option.
You may use special comments to disable some warnings.
Use // eslint-disable-next-line to ignore the next line.
Use /* eslint-disable */ to ignore all warnings in a file.
App running at:
- Local: http://localhost:8080
- Network: http://192.168.0.105:8080
Like this it show the warning message every time compiling. any way to fix this intent waning using vscode
As noted in the error message, you can fix the problem by running the following command:
$ npm run lint -- --fix
In the future, you can get VSCode to automatically fix these problems by installing the ESLint extension, and enabling the eslint.autoFixOnSave option as documented here: https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint

How to remove the whole column in vue table?

I have a problem in removing the whole column and its corresponding row in vue-table.
Here is my code.
<b-table :fields="fields" :items="data">
<template slot="action" slot-scope="data" v-if="authorize = 1">
</template>
</b-table>
export default{
data(){
authorize: 0,
data: [],
fields: [
{key: 'id', label: '#'},
{key: 'name', label: 'Name'},
{key: 'action', label: 'Action'}
],
}
}
In this case, When I use v-if inside the <template> it only removes the corresponding row of the column.
This is the result of the code above
| # | Name | Action |
----------------------------------------
| 1 | John Doe | |
| 2 | Chicharon Ni Mang Juan | |
| 3 | Lumanog | |
My Problem is, I want to remove the column itself like this.
| # | Name |
------------------------------
| 1 | John Doe |
| 2 | Chicharon Ni Mang Juan |
| 3 | Lumanog |
#Regards,
With vue-tables-2 I don't think there's any other choice but to have conditional for different column sets, like in computed. For example:
computed: {
fields: function() {
let fields = [{key: 'id', label: '#'}, {key: 'name', label: 'Name'}]
if (this.authorize === 1) {
fields.push({key: 'action', label: 'Action'})
}
return fields
}
}
I just found a simple solution by not using the table on this way:
<b-table :fields="fields" :items="data">
<template slot="action" slot-scope="data" v-if="authorize = 1">
</template>
</b-table>
I just used this simple html table:
<table class="table" style="width:100%">
<thead>
<tr>
<th>#</th>
<th>Name</th>
<th v-if="authorize == 1">Action</th>
</tr>
</thead>
<tbody>
<tr v-for="user in data">
<td>{{ user.id }}</td>
<td>{{ user.name }}</td>
<td v-if="authorize == 1">
<button variant="primary">Delete</button>
</td>
</tr>
</tbody>
</table>
Here, I can easily manipulate to remove/show the column and its data.
Thanks!

Lotus Script Agent not working on Domino 9 server

I have an export to Excel agent that works great on my old 8.5 server. When I moved the database to a 9.0.1 server, the agent only exports one line at a time. If there are 30 lines in the view, you have to run the agent 30 times. What is different on a Domino 9 that would stop the agent from running through each line in the view?`Sub WriteViewasExcel (view As NotesView)
%REM
Agent ExporttoExcel
Created Mar 11, 2010 by Brian Moore/usr/nbt
Description: Comments for Agent
%END REM
Option Public
Option Declare
Sub Initialize()
Dim s As New NotesSession
Dim db As NotesDatabase
Dim qs As NotesView
Dim nv As NotesViewNavigator
Dim ne As NotesViewEntry
Dim Doc As NotesDocument
Set db = s.Currentdatabase
Set qs = db.GetView("Export")
Set nv = qs.CreateViewNav
Set ne = nv.GetFirst
Dim filename As String
Print |Content-Type:application/vnd.ms-excel|
filename="Excel "+db.Title+" "+Format(Now, "yyyy-mmm-d hhmm")+".xls" 'file name which will be suggested to user to save the resulting Excel file
Print |Content-Disposition: Attachment; filename="|+filename+|"| 'Triggers the save/open browser prompt instead of embedding the spreadsheet in the browser
Print ""
Print |<table border="1"><tr>
<td width="135"> <Center><b>Store Name</td></b>
<td width="80"> <Center><b>Date</td></b>
<td width="80"> <Center><b>Nontax clothing sales</td></b>
<td width="80"> <Center><b><font color="blue">Tax textile sales</td></b></font>
<td width="80"> <Center><b><font color="red">Furniture Sales</td></b></font>
<td width="80"> <Center><b><font color="green">Elec/Mech Appl/Fixture Sales</td></font> </b>
<td width="80"> <Center><b> Shoe Sales</td></b>
<td width="80"> <Center><b><font color="blue">Wares Sales</td></b></font>
<td width="80"> <Center><b><font color="red">Total Discounts</td></b></font>
<td width="80"> <Center><b><font color="green">Taxable Income</td></font> </b>
<td width="80"> <Center><b>Tax Amount</td></b>
<td width="80"> <Center><b><font color="blue">Credit Total</td></b></font>
<td width="80"> <Center><b><font color="red">Payout Total</td></b></font>
<td width="80"> <Center><b><font color="green">Actual Deposit</td></font> </b>
<td width="80"> <Center><b>MC/VISA Sales</td></b>
<td width="80"> <Center><b><font color="blue">AMEX Sales</td></b>
<td width="80"> <Center><b><font color="red">Gift Certificates</td></b>
<td width="80"> <Center><b>Customer Count</td></b>
<td width="80"> <Center><b>Total Donations</td></b></font></Center>
</tr>|
While Not(ne Is Nothing)
Set doc = ne.Document
Call doc.ReplaceItemValue("exported" , "yes")
Call doc.Save(True, False)
Print|<tr> <td>| + ne.ColumnValues(0) + |</td> | 'Store Name
Print|<td> | + ne.ColumnValues(1) + | </td> | 'Date
Print|<td> | + ne.ColumnValues(2) + | </td> | 'Non Tax Clothing Sales
Print|<td> <font color="blue">| + ne.ColumnValues(3) + | </font> </td> | 'Taxable Textile Sales
Print|<td> <font color="red">| + ne.ColumnValues(4) + | </font> </td> | 'Furniture Sales
Print|<td> <font color="green">| + ne.ColumnValues(5) + | </font> </td> | 'Elec/Mech Appliance/Fixture Sales
Print|<td> | + ne.ColumnValues(6) + | </td> | 'Shoe Sales
Print|<td> <font color="blue">| + ne.ColumnValues(7) + | </font> </td> | 'Wares Sales
Print|<td> <font color="red">| + ne.ColumnValues(8) + | </font> </td> | 'Total Discounts
Print|<td> <font color="green">| + ne.ColumnValues(9) + | </font> </td> | 'Taxable Income
Print|<td> | + ne.ColumnValues(10) + | </td> | 'Tax Amount
Print|<td> <font color="blue">| + ne.ColumnValues(11) + | </font> </td> | 'Credit Total
Print|<td> <font color="red">| + ne.ColumnValues(12) + | </font> </td> | 'Payout Total
Print|<td> <font color="green">| + ne.ColumnValues(13) + | </font> </td> | 'Actural Deposits
Print|<td> | + ne.ColumnValues(14) + | </td> | 'MC/VISA Sales
Print|<td> <font color="blue">| + ne.ColumnValues(15) + | </font> </td> | 'AMEX Sales
Print|<td> <font color="red">| + ne.ColumnValues(16) + | </font> </td> | 'Gift Certificates
Print|<td> <font color="red">| + ne.ColumnValues(17) + | </font> </td> | 'Customer Count
Print|<td> <font color="red">| + ne.ColumnValues(18) + | </font> </td> | 'Total Donations
Set ne = nv.GetNext(ne)
Wend
End Sub
Add after the code line
Set qs = db.GetView("Export")
the line
qs.AutoUpdate = False
Your view navigator gets confused when documents get discarded from view while navigator tries to get from entry to entry. qs.AutoUpdate = False prevents all entries in view during agent run.

SQL query for dynamic table column selection from checkbox in codeigniter?

I am trying to retrieve the columns from the database based on checkbox selection in codeigniter. But I have no idea how to do it?
For example there's a columns in a database table Member:
| ID | Name | Gender | Status |
---------------------------------------
| 1 | Anne | F | Member |
| 2 | Brown | M | Member |
| 3 | Carl | M | Member |
Then there's checkboxes in the data.php view to select which column to display
<?php echo form_open(data/getData);?>
<label class="col-md-4" for="parameter">Parameter</label>
<div class="col-md-6">
<input type="checkbox" id="parameter" value="name"> Name <br>
<input type="checkbox" id="parameter" value="gender"> Gender <br>
<input type="checkbox" id="parameter" value="status"> status <br>
</div>
<input type="submit" class="btn btn-md btn-info" value="Process" />
<?php echo form_close();?>
<div class="well">
<table class="table table-bordered table-hover" cellspacing="0" width="100%">
<thead>
<tr class="info">
<th>ID</th>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<?php foreach($query as $d): ?>
<tr>
<td><?php echo $d['ID'];?></td>
<td><?php echo $d[''];?></td>
<td><?php echo $d[''];?></td>
<td><?php echo $d[''];?></td>
</tr>
<?php endforeach ?>
</tbody>
</table>
</div>
How to dynamically make the column name retrieved from the checkbox?
Data_model.php:
function getData(){
//I don't know how to get the dynamic column select from the view to the select query
$this->db->select(?);
$this->db->from('member');
$query = $this->db->get();
return $query->result();
}
Anyone help me with this please?
Try this simple approach , make a POST/GET with a name attribute param[] an array
<input type="checkbox" id="parameter" name="param[]" value="name"> Name <br>
<input type="checkbox" id="parameter" name="param[]" value="gender"> Gender <br>
<input type="checkbox" id="parameter" name="param[]" value="status"> status <br>
in PHP (assuming post value)
$param = $this->input->post('param');
//if no param get all columns
if(empty($param)){
$param = '*';
}else{
//if array value is more than 1 use implode else just take the 1st array
$param = (count($param) > 1 ) ? implode(',', $param) : $param[0]; //make a single string and concatenate them with ,
}
example output: name,status
then use $param in your model like this $this->db->select("$param");