Bootstrap Template: Using the template for all the views - css

I'm trying to add the Gentelella template to my ASP.NET Core project.
The main problem is that the content of my current pages (any index page) is not merged with the template:
Expected Value:
Current Value:
The problem:
I'm trying to figure out how to show these components (index view inside and layout) together, as shown in picture 1.
For this, I found the code inside the _Layout that encapsulates the Plain Page section:
Should I make the call of my index view in that section? How?
PartialView rings a bell.
Calling the Controllers and actions:
<li>
<a><i class="fa fa-edit"></i> Tiendas <span class="fa fa-chevron-down"></span></a>
<ul class="nav child_menu">
<li><a asp-area="" asp-controller="Stores" asp-action="Index">Nueva Tienda</a></li>
<li>Editar Tiendas</li>
</ul>
</li>
Section inside the Template where the Index should show:
<div class="row">
<div class="col-md-12 col-sm-12 col-xs-12">
<div class="x_panel">
<div class="x_title">
<h2>Plain Page</h2>
<ul class="nav navbar-right panel_toolbox">
<li>
<a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
</li>
<li class="dropdown">
<i class="fa fa-wrench"></i>
<ul class="dropdown-menu" role="menu">
<li>
Settings 1
</li>
<li>
Settings 2
</li>
</ul>
</li>
<li>
<a class="close-link"><i class="fa fa-close"></i></a>
</li>
</ul>
<div class="clearfix"></div>
</div>
<div class="x_content">
Add content to the page ...
</div>
</div>
</div>
</div>
Example of Index View:
#model IEnumerable<Application.Models.Tienda>
#using Application.Models
#{
ViewData["Title"] = "Index";
}
#Html.Partial("_NavBar")
<h2>Tiendas</h2>
#*data-toggle tells bootstrap what to do*#
#*data-target tells bootstrap which element is going to open*#
<div class="btn-group" id="modalbutton">
<a id="createEditStoreModal" data-toggle="modal" asp-action="Create" data-target="#modal-action-store"
class="btn btn-primary">
<i class="glyphicon glyphicon-plus"></i> Nueva Tienda
</a>
</div>
<p></p>
<table id="stores" class="table table-bordered table-hover table-striped">
<thead>
<tr>
<th>
Provincia
</th>
<th>
Marca Comercial
</th>
<th>
Cadena
</th>
<th>
Tienda
</th>
<th>Editar</th>
</tr>
</thead>
<tbody>
#foreach (var item in Model)
{
<tr>
<td>
#Html.DisplayFor(modelItem => item.Districts.Provincias.provincia_nombre)
</td>
<td>
#Html.DisplayFor(modelItem => item.tienda_marca)
</td>
<td>
#Html.DisplayFor(modelItem => item.tienda_cadena)
</td>
<td>
#Html.DisplayFor(modelItem => item.tienda_nombre)
</td>
<td>
<div class="btn-group" id="modalbuttonedit">
<a id="editStoreModal" data-toggle="modal" asp-action="Create"
data-target="#modal-action-store" asp-route-id="#item.tienda_id" class="btn btn-info">Edit</a>
</div>
</td>
</tr>}
</tbody>
</table>

Solved it.
The proper way to position your Index view inside the _Layout is using the #RenderBody() wherever you want to load your view information.
In this case, it was where I indicated it in the question.
There is also the option to render your scripts, if any. #RenderSection("Scripts", required: false)
We have to be careful with that since the script might run locally but not once the project is in production because of bad placement.
The final picture is this:

Related

The anchor element doesn't recognized on specify positions with tag helpers .Net core 6

I'm working with .Net Core 6 and currently I have problems to make it works the elements with tag helpers.
<div class="container p-3">
<div class="row pt-4">
<div class="col-6">
<h2 class="text-primary">Category List</h2>
</div>
<div class="col-6 text-end">
<a asp-controller="Category" asp-action="Create" class="btn btn-primary">
<i class="bi bi-plus-circle"></i> Create new category
</a>
</div>
</div>
<br /><br />
<table class="table table-bordered table-striped" style="width: 100%;">
<thead>
<tr class="table-primary" ">
<th scope="row">Category Name</th>
<th scope="row">Display Order</th>
<th></th>
</tr>
</thead>
<tbody>
#foreach (var category in Model)
{
<tr>
<td width="50%">#category.Name</td>
<td width="30%">#category.DisplayOrder</td>
<td>
<div class="w-75 btn-group" role="group">
<a asp-controller="Category" asp-action="Edit" asp-route-id="#category.Id" class="btn btn-primary mx-2">
<i class="bi bi-pencil-square"></i> Edit
</a>
</div>
</td>
</tr>
}
</tbody>
</table>
Here the first anchor works perfectly,
<a asp-controller="Category" asp-action="Create" class="btn btn-primary">
<i class="bi bi-plus-circle"></i> Create new category
</a>
But when I'm using the next one, and I run the application, the navigator does not recognize the tag and does not create automatically the sintax to add the href tag.
<a asp-controller="Category" asp-action="Edit" asp-route-id="#category.Id" class="btn btn-primary mx-2">
<i class="bi bi-pencil-square"></i> Edit
</a>
After testing, I finally found the reason.
The problem is with this line of code:
<tr class="table-primary" ">
It has one more ".
Remove it, the href will be displayed normally.
<tr class="table-primary">

Materialize CSS dropdown inside ngFor Angular 8

I'm trying to add a Materialize dropdown inside a table generate with *ngFor and the dropdown didn't show.
If I put the dropdown code outside the table it works.
<p>Users enabled in this node: {{usersEnabled}}</p>
<p>Users in this node: {{users.length}}</p>
<table>
<thead>
<th>
Email
</th>
<th>
Enabled
</th>
<th>
Actions
</th>
</thead>
<tbody>
<tr *ngFor="let user of users">
<td>
{{user.username}}
</td>
<td class="isLink cursorIcon" (click)="enableDisableUser(user.apiKey)">
{{user.enabled}}
</td>
<td>
<!-- Dropdown Structure -->
<!-- <button class="btn" (click)="resetPassword(user)">Reset password</button> -->
<a class='dropdown-trigger btn' data-target='dropdown{{user.apiKey}}'>Drop Me!</a>
<ul id='dropdown{{user.apiKey}}' class='dropdown-content'>
<li>one</li>
<li>two</li>
<li class="divider" tabindex="-1"></li>
<li>three</li>
<li><i class="material-icons">view_module</i>four</li>
<li><i class="material-icons">cloud</i>five</li>
</ul>
</td>
</tr>
</tbody>
</table>
Typescript important methods
ngOnInit() {
this.getUsers();
}
private getUsers(): void {
this.userService.getUsersByNodeApiKey(this.nodeKey).subscribe(
res => {
this.usersEnabled = res.filter((user: User) => user.enabled).length;
this.users = res.sort((a, b) => a.enabled < b.enabled ? 1 : -1);
M.AutoInit();
var elems = document.querySelectorAll('.dropdown-trigger');
var instances = M.Dropdown.init(elems, {autoTrigger: true});
},
err => console.error(err)
);
}
I'm using Angular 8 and Materialize CSS 1.0
For that you need to add [innerHTML] which enables generated html inside your table like this
[innerHTML]="user.dropdown"
Where as user.dropdown may be an empty string defined in your .ts file or some value which you want to use in drop-down.
May be in your case user.apiKey can also be used.
Try rendering the table / row in the view once users scope has it's data by add a
<ng-container *ngIf="users.length">
<tr *ngFor="let user of users">
.
.
.
</tr>
</ng-container>
Hope this helps!
Hey #Marc Serret i Garcia... I have found a work around. Try if my provided solution works:-
<tbody>
<tr *ngFor="let user of users">
<td>
{{user.username}}
</td>
<td class="isLink cursorIcon" (click)="enableDisableUser(user.apiKey)">
{{user.enabled}}
</td>
<td>
<!-- Dropdown Structure -->
<!-- <button class="btn" (click)="resetPassword(user)">Reset password</button> -->
<a class='dropdown-trigger btn' [attr.data-target]='user.apiKey'>Drop Me!</a>
<ul [id]='user.apiKey' class='dropdown-content'>
<li>one</li>
<li>two</li>
<li class="divider" tabindex="-1"></li>
<li>three</li>
<li><i class="material-icons">view_module</i>four</li>
<li><i class="material-icons">cloud</i>five</li>
</ul>
</td>
</tr>
</tbody>
Look for the changes that I have made -
<a class='dropdown-trigger btn' [attr.data-target]='user.apiKey'>Drop Me!</a>
And the other for the id of dropdown - <ul [id]='user.apiKey' class='dropdown-content'>. It worked for me. Hope this helps.
Please look at my stackblitz:- https://stackblitz.com/edit/multipledropdown

Dropdown is getting cropped out when using the ui-scroll directive

When I go to the last row (no. 25) and click edit you will see that the dropdown it's cropped out. Can you figure out how to solve this issue?
https://plnkr.co/edit/22e9bo?p=preview
<div ui-scroll-viewport class="col-md-12" style="height: 500px; border: dashed 1px #ddd;">
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>id</th>
<th>source</th>
<th>destination</th>
</tr>
</thead>
<tbody>
<tr ui-scroll="item in datasource">
<td>{{item.id}} <a ng-click="showDropdown(item.id)">edit</a></td>
<td>{{item.source}}</td>
<td ng-if="dropdowns.active !== item.id">{{item.destination}}</td>
<td ng-if="dropdowns.active === item.id">
<div class="dropdown">
<button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
{{item.destination}}
<span class="caret"></span>
</button>
<ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
<li>10.0.0.0</li>
<li>10.255.255.255</li>
<li>172.16.0.0</li>
<li>172.31.255.255</li>
<li>192.168.255.255</li>
<li role="separator" class="divider"></li>
<li>192.168.0.0</li>
</ul>
</div>
</td>
</tr>
</tbody>
</table>
</div>
Generally, this is not the ui-scroll issue, this is how the Bootstrap hosts it's dropdown menu in DOM. If the hoster element has overflow-y: scroll, then you'll get the situation you described in your question. As an angular-way solution I would suggest to use angular-ui wrapper for the Bootstrap: https://angular-ui.github.io/bootstrap/.
They have Dropdown directive which has dropdown-append-to and dropdown-append-to-body settings which allow you to append your Bootstrap dropdown to any element. This will solve the issue.

Bootstrap table with multiple row

I want a "large" table to be beautiful in both mobile devices and desktop. Without x-scrolling.
One way, I think, is to create a table row which is high (two rows, with rowspan=2).
But is there a smoother and more good-looking way to make this? This example below is okay, but I still think it's possible to make the result more clean and nicer.
One problem is also that I can't use ant filter plugins and pagination, as the scripts think that one row is two rows.
Any ideas?
<div class="container">
<div class="table-responsive">
<table class="table">
<tbody>
<tr class="bg-danger">
<td rowspan=2>
<div class="dropdown">
<button class="btn btn-danger dropdown-toggle btn-md" type="button" data-toggle="dropdown" onclick="">+
<span class="caret"></span></button>
<ul class="dropdown-menu">
<li>Edit</li>
<li class="bg-danger">Delete</li>
</ul>
</div>
</td>
<td>
<div>
<h4>Christian A</h4></div>
</td>
<td>
<h4 class="pull-right">133 €</h4></td>
</tr>
<tr class="bg-danger">
<td colspan=2>
2014-05-05 - Not paid
</td>
</tr>
<tr class="bg-success">
<td rowspan=2>
<div class="dropdown">
<button class="btn btn-danger dropdown-toggle btn-md" type="button" data-toggle="dropdown" onclick="">+
<span class="caret"></span></button>
<ul class="dropdown-menu">
<li>Edit</li>
<li class="bg-danger">Delete</li>
</ul>
</div>
</td>
<td>
<div>
<h4>Nicolaus S</h4></div>
</td>
<td>
<h4 class="pull-right">122 €</h4></td>
</tr>
<tr class="bg-success">
<td colspan=2>
2014-05-05 - Payed
</td>
</tr>
</tbody>
</table>
</div>
</div>
http://jsfiddle.net/weuf6vb3/

Angular Ui bootstrap dropdown split-button issue with table

I have an angular app , and have integrated angular-ui-bootstrap , my issue is that the dropdown links are are being blocked by table row , using z-index :
<div class="panel panel-default">
<div class="panel-body">
<div class=" pull-right">
<!-- Split button -->
<div class="btn-group invoice_new_item_btn_ul" uib-dropdown>
<button id="split-button" type="button" class="btn btn-danger"> Add Item </button>
<button type="button" class="btn btn-danger" uib-dropdown-toggle>
<span class="caret"></span>
</button>
<ul class="invoice_new_item_btn_ul uib-dropdown-menu" role="menu" aria-labelledby="split-button">
<li role="menuitem">Action</li>
</ul>
</div>
</div>
<div class="table-responsive">
<table class="table table-striped" >
<thead>
<tr>
<th></th>
<th>Item Name</th>
<th>Type</th>
</tr>
</thead>
<tbody id="search_result">
<tr class="odd gradeX" ng-repeat="u in vm.patient.patient_finance_item">
<td></td>
<td ng-bind="u.item_name"></td>
<td ng-bind="u.item_type"></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
The css/sass :
.invoice_new_item_btn_ul{
z-index:1000 !important;
}
uib-dropdown-menu only works as an attribute, not a class, which is why your drop down menu is not displaying.
https://github.com/angular-ui/bootstrap/blob/master/src/dropdown/dropdown.js#L285-L287

Resources