React-Paginate causing table component to throw react Hydration issue - html

I'm having an issue where my table component is throwing due to the React-Paginate package having a list for the pagination, a UL cannot be a child of a <tbody/ tag, causing React to throw a hydration error whenever I reload the page, this is my component code below, and below that is also my Items code, which is what paginated items renders for each item in the array.
<table className="table-auto w-full">
<thead>
<tr>
<th className="p-1 whitespace-nowrap float-left">
{headers[0]}
</th>
<th className="p-1 whitespace-nowrap">
<p className="float-right">{headers[1]}</p>
</th>
</tr>
</thead>
<tbody>
<PaginatedItems itemsPerPage={paginateItemsNum} />
</tbody>
</table>
Items Code:
function Items({ currentItems }) {
return (
<>
{currentItems &&
currentItems.map((item) => (
<tr key={item.Id}>
<td className="p-2 whitespace-nowrap">
<div className="flex items-center">
<div className="font-medium text-black float-left">
{item.Name}
</div>
</div>
</td>
<td className="p-2 whitespace-nowrap">
<div>
<div className="font-medium text-black float-right">
{item.EnabledString}
</div>
</div>
</td>
</tr>
))}
</>
);
}

Related

HTML Table wrap col data to fit to the view

Have a question about the HTML view related to the table.
In my HTML view, I have a table.
This is worked in a responsive way when changing the view.
Here I want to change the view that the responsive view comes with a scroll bar.
I want to change it to fit all columns to the view and wrap the column contents.
Any suggestions to do it?
<div class="col-md-12 col-sm-12 grid-margin stretch-card">
<div class="card shadow-card-l">
<div class="card-body">
<center><h4 class="card-title">Task Related Documents</h4></center>
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th>Document Type</th>
<th>Document Note</th>
<th>File Name</th>
<th></th>
</tr>
</thead>
<tbody>
#foreach (var item in Model.TaskFilesHistoryViewModel.OrderByDescending(x => x.Id))
{
<tr class="even pointer">
<td>#item.File_Type</td>
<td>#item.Note</td>
<td>#item.File_Name</td>
<td>
<a href="#Url.Action("DownloadTaskImage","Ajax", new { id = item.Id})" target="_blank" rel="publisher tag" class="btn btn-outline-info ti-import" />
<a href="#Url.Action("RetrieveTaskImage","Ajax", new { id = item.Id})" target="_blank" rel="publisher tag" class="btn btn-outline-success fa ti-eye" />
</td>
</tr>
}
</tbody>
</table>
</div>
</div>
</div>
</div>

how to display a blob file (image) from mysql using laravel

how to get the blob file (photo) that has already existed from MySQL using laravel, I am creating contact detail for the employee and it needs a photo and some of those employees don't have a picture in the database. beginners here. :)
this my controller
public function index()
{
$user = DB::table("user_basic")
->leftjoin("user_status","user_status.status_id" , "=" , "user_basic.user_id")
->leftjoin("user_employment","user_employment.emp_id" , "=" , "user_basic.user_id")
->leftjoin("user_photo","user_photo.photo_id" , "=" , "user_basic.user_id")
->select("user_status.*", "user_basic.*" , "user_employment.*","user_photo.*" )
->get();
if (request()->filled('status') && request('status') !== null) {
$user = $user->where('status_xtitle', request()->status);
}
$datatables = datatables::of($user);
return view("pages.Directory.index")->with("user",$user);
}
this is the index.blade where I will put the photo
</div>
<div class="row ">
<div class="col-12">
<div class="card-body">
<table class="table table-hover table-fw-widget " id="table4">
<thead>
<tr>
<th scope="col">Employee's information</th>
<th scope="col">Contacts</th>
<th scope="col">Employment</th>
</tr>
</thead>
<tbody>
#foreach ($user as $user)
<tr>
<td scope="row">
<div class="d-flex align-items-center">
<img src="" alt="">
<div>
<P><h6>
<?php
$arr = array($user->user_xfirstname,
$user->user_xmiddlename,
$user->user_xlastname);
echo join(" ",$arr);
?>
</h6></P>
<p id = "status"><small class= "text-muted">{{$user->status_xtitle}}</small> </p>
</div>
</div>
</td>
<td></td>
<td></td>
<td></td>
</tr>
#endforeach
</tbody>
</table>
</div>
</div>
<div class="col-1"></div>
</div>
</form>

Ngbpopover is not taking the external css that is define in ng-template when container="body" is used in ngbpopover

I want my ngbpopover to appear at the top of the parent element as it is appearing below the parent element. I had put container="body" in ngbpopover that fix the given issue but somehow the external css is not appearing that I had defined in ng-template.
<mat-tab-group animationDuration="0ms">
<div *ngFor="let sampleData of sampleDataInfo[j]; let i=index">
<mat-tab label="{{targetData[j][i].fullName}}">
<table class="source-target-Info-table">
<tr class="source-target-Table">
<th><img data-toggle="tooltip" data-placement="bottom" title="Sub1"></th>
<th>row2</th>
<th>row3</th>
<th>row4</th>
<th>row5</th>
<th>row6</th>
<th>row7</th>
<th>row8</th>
<th>row9</th>
<th>row10</th>
</tr>
<tr *ngFor="let target of targetData[j][i].files; let file=index">
<td>
<a class="info-link" href="javascript:;" title=" Log-{{sampleData?.sessionId}}" (click)="openDexLog(j,i)">
{{(1)}}
</a>
</td>
<td *ngIf="target.qualityLevel > 0; else negativeQuality">
**<a class="info-link" href="javascript:;" title="Click to see Quality result files" href="javascript:;" placement="top-left" popoverClass="popover-class" [ngbPopover]="popContentQuality" container="body">{{target.qualityLevel}}</a>**
</td>
**
<ng-template class="quality-popover" #popContentQuality>**
<h1 class="quality-heading">Quality Results for</h1>
<h3 class="file-name">{{target.name}}</h3>
<table class="source-target-Info-table">
<tr class="source-target-Table">
<th>FILE NAME</th>
<th>SIZE</th>
<th>DESCRIPTION</th>
</tr>
<tr *ngFor="let tq of tqData; let i=index">
<td>
<a class="info-link" href="javascript:;">{{tq.name}}</a>
</td>
<td>{{tq.size/1000}} KB</td>
<td>{{tq.description}}</td>
</tr>
</table>
</ng-template>
</tr>
</table>
</mat-tab>
</div>
</mat-tab-group>
It is only taking the css if is defined in inline format ( using style). Is there any to make the external css working when container="body" for ngbpopover in ng-template? I had also tried to define the external css in the component that consist of body tag but that doesn't work for me. Any suggestions regarding this will be helpful.
Probably styles incapsulated in :host selector. Input container="body" makes you tooltip content not inside host component.

Parent div issue in datepicker

While clicking date picker icon it navigates to the bottom of the table.because it's not fit to the td tag,
So it searching for next parent div tag.The next div tag is a table.So it navigates to the bottom of the table. any solution for that.
Actually, after clicking the icon, it navigates to the bottom. Again I need to scroll up to see the date picker
After click icon
after i need to scroll up to see the date picker
HTML:
<div class="row grid-main m-0">
<div class="col-md-12">
<div class="grid-table table-responsive">
<table class="table">
<thead>
<tr>
<th> {{'911_LBL_MONTH' | translate}}</th>
<th>{{'911_LBL_FRMDATE' | translate}} <sup class="required">*</sup></th>
<th>{{'911_LBL_TODATE' | translate}} <sup class="required">*</sup></th>
<th>
<sortable-header [headerText]="'911_LBL_UPDATEDBY'" [sortField]="'ModifiedBy'" [items]="applicationdetail" (changeCurrentSortField)="changeCurrentSortField($event)"
[currentSortField]="currentSortField"></sortable-header>
</th>
<th>
<sortable-header [headerText]="'911_LBL_LASTUPDATED'" [sortField]="'ModifiedDate'" [items]="applicationdetail" (changeCurrentSortField)="changeCurrentSortField($event)"
[currentSortField]="currentSortField"></sortable-header>
</th>
<th class="text-center">{{'911_LBL_APPCOUNT' | translate}} </th>
</tr>
</thead>
<tbody>
<ng-template [ngTemplateOutlet]="tmpltTbl"
[ngTemplateOutletContext]="{ $implicit: itm, idx: i }"></ng-template>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<ng-template #tmplt let-item>
<tr *ngFor="let item of applicationdetail; let i = index">
<td>{{montharray[i] | translate}}</td>
<td *ngIf="item.FromDate">
<div>
<app-date [inputDate]="item.FromDate" [index]="i"
(emitDate)="assignFromDate($event,i)"
[minDate]="minDate[i]"
[maxDate]="maxDate[i]"
[isDisabled]="item.DisablePassedFromDate"
controlName="FromDate{{i}}"
[isConditional]="true"></app-date>
</div>
</td>
<td *ngIf="item.ToDate">
<div>
<app-date [inputDate]="item.ToDate" [index]="i"
(emitDate)="AssignToDate($event,i)"
[minDate]="toMinDate[i]"
[maxDate]="toMaxDate[i]"
[isDisabled]="item.DisablePassedToDate || item.FromDate==null"
controlName="ToDate{{i}}"
[isConditional]="true"></app-date>
</div>
</td>
<td> {{isEnglish ? item.ModifiedBy : item.ModifiedBy_AR}} </td>
<td>{{item.ModifiedDate}}</td>
<td class="text-center"><button type="submit" class="btn btn-primary btn-radius" (click)="openDialog(this.item,i)" data-backdrop="static" data-toggle="modal" data-keyboard="false" data-target="#myModal" value="submit" title="{{'CMN_BTN_MANAGETITLE' | translate}}">{{'911_LBL_MANAGE' | translate}} </button></td>
</tr>
</ng-template>
Thanks in advance
So it searching for next parent div tag.The next div tag is a table.So it navigates to the bottom of the table. any solution for that.
As I understand you find, that problem in the parent div tag, that is far away from your datepicker showing place.
So you can add second parent div where you want it.
For example:
<div style="position: relative;">
<div style="position: relative;">
<app-date [inputDate]="item.FromDate" [index]="i"
(emitDate)="assignFromDate($event,i)"
[minDate]="minDate[i]"
[maxDate]="maxDate[i]"
[isDisabled]="item.DisablePassedFromDate"
controlName="FromDate{{i}}"
[isConditional]="true"></app-date>
</div>
</div>
Don't forget to try with position: relative; - It also can be reason of problem.

Table data overflowing past container

When a field value is too long in my bootstrap table, the table will extend to the length of the parameter even if its past the container. The only way I was able to somewhat prevent this is by using responsive-table, however then a scroll bar shows up on the bottom and you have to scroll all the way to the right to see the table data. How can I make it so when my table reaches the length of the container, the row data will wrap?
Here is an image of what is going on: http://i.stack.imgur.com/Bo1dO.jpg
Here is a portion of my view, the CSS and example can be seen here: https://jsfiddle.net/bsxtpoqd/
<div class="container">
<div class="row tab-content">
<div class="row">
<h3>Assigned Games</h3>
<p>Please enter a search string in the textbox to search for users</p>
<form class="form-inline">
<div class="form-group">
<input type="text" class="form-control" id="tableSearch" placeholder="Enter search term...">
</div>
</form>
<div class="table">
<table id="userTable" class="table">
<thead>
<tr>
<th>UserName</th>
<th>Alternate</th>
<th>Email</th>
<th>Assigned Games</th>
<th>Unassigned Games</th>
</tr>
</thead>
<tbody>
#foreach (var user in Model)
{
<tr>
<td>#Html.ActionLink(user.UserName, "_GameAssigner", "Admin", new { insUserId = user.InstitutionUserId }, new { #class = "modal-link" })</td>
<td>
#user.AlternateId
</td>
<td>#user.Email</td>
<td>
#if (user.Assigned.Any())
{
<a href="#" tabindex="0" role="button" data-toggle="popover" title="Games" data-trigger="focus"
data-content="#foreach (var gameName in user.Assigned){<div>#gameName</div>}">
#user.Assigned.Count</a>
}
else
{
<div class="text-warning">0</div>
}
</td>
<td>
#if (user.Unassigned.Any())
{
<a href="#" tabindex="0" role="button" data-toggle="popover" title="Games" data-trigger="focus"
data-content="#foreach (var gameName in user.Unassigned) {<div>#gameName</div>}">
#user.Unassigned.Count</a>
}
else
{
<div class="text-warning">0</div>
}
</td>
</tr>
}
</tbody>
</table>
</div>
</div>
</div>
</div>
You need to break up the long word.
<td style="word-break:break-all">
This is you need:
<style>
td
{
word-break: normal;
}
</style>