Make 2 buttons inside a table cell be next to each other - html

I have the following code :
<td>
<button class="btn btn-primary btn-xs" ng-click="r.changeView('requests/edit/' + request.id)">
<i class="fa fa-pencil-square-o"></i>
</button>
<button class="btn btn-primary btn-xs" ng-click="r.changeView('requests/edit/' + request.id)">
<i class="fa fa-step-backward"></i>
<i class="fa fa-step-forward"></i>
</button>
</td>
They appear on 2 different lines.
How can I make them appear next to each other on the same line ?
I tried a few things with float and display but without success.

If I add that code in a snippet the buttons are next to each other, so it's hard to reproduce:
<table>
<tr>
<td>
<button class="btn btn-primary btn-xs" ng-click="r.changeView('requests/edit/' + request.id)">
<i class="fa fa-pencil-square-o"></i>Button1
</button>
<button class="btn btn-primary btn-xs" ng-click="r.changeView('requests/edit/' + request.id)">
<i class="fa fa-step-backward"></i>
<i class="fa fa-step-forward"></i>Button2
</button>
</td>
</tr>
</table>
The buttons are already displayed as inline-block.
Maybe the table isn't wide enough; if so, You could try <td style='white-space: nowrap'>.

If you're using Bootstrap, try using classes like "pull-left". This will float both of the buttons left and bring them inline. Also check to be sure nothing is overriding the current display attribute.
<div class="pull-left">...</div>
<div class="pull-right">...</div>

Did you tried display: inline-block;?
However that seems unnecessary because two buttons in the same table cell will appear on the same line.
table,
td,
tr {
border: 1px solid black;
border-collapse: collapse;
}
<table>
<tr>
<td>
<button>Button1</button>
<button>Button2</button>
</td>
</tr>
</table>

What you need is just css display inline code, which can be use to format your button
form {
display: inline;
}
this displays an element as an inline element like span

Please see how to use <table> tag inside in <td> and get all button in line.
<table>
<td>
<table>
<tr>
<td>
<button class="btn btn-primary btn-xs">Add</button>
</td>
<td>
<button class="btn btn-primary btn-xs">Edit</button>
</td>
<td>
<button class="btn btn-primary btn-xs">View</button>
</td>
</tr>
</table>
</td>
</table>

Related

Submit not submitting form but moving cursor to input field

I'm out of options and a bit frustrated. I'm not that familiar with HTML but I have got two forms one where a button of the type="submit" sends my view model to the server side controller and this here where it does not do it. In this form, if I click the submit button the cursor gets moved to the Surcharges[i].Price input field in my table instead. The only difference between the two forms is that this form here has input fields in the table whereas the other has select fields.
<form autocomplete="off" asp-controller="PriceList" asp-action="UpdateSurchargeFixPrices" enctype="multipart/form-data">
<div class="container">
<div class="card">
<div class="card-header bg-primary text-white">
<h4 class="text-center">#localizer["PriceListEdit"]</h4>
</div>
<div class="card-body">
<input hidden value="#Model.BackTo" asp-for="BackTo" />
<table class="table">
<thead>
<tr class="table-secondary">
<th>#localizer["Bezeichnung"]</th>
<th>#localizer["Gruppe"]</th>
<th>#localizer["Code"]</th>
<th>#localizer["Maximaler Wert in"] #Model.Currency</th>
<th>#localizer["Preis in"] #Model.Currency</th>
</tr>
</thead>
<tbody>
#if (Model.Surcharges != null)
{
for (int i = 0; i < Model.Surcharges.Count; i++)
{
<tr>
<td><input hidden value="#Model.Surcharges[i].Id" asp-for="Surcharges[i].Id" /><input value="#Model.Surcharges[i].Description" asp-for="Surcharges[i].Description" /></td>
<td>
<input value="#Model.Surcharges[i].Group" asp-for="Surcharges[i].Group" />
</td>
<td>
<input value="#Model.Surcharges[i].Code" asp-for="Surcharges[i].Code" />
</td>
<td>
<input value="#Model.Surcharges[i].MaxValue" asp-for="Surcharges[i].MaxValue" />
</td>
<td>
<input value="#Model.Surcharges[i].Price" asp-for="Surcharges[i].Price" />
</td>
</tr>
}
}
</tbody>
</table>
</div>
</div>
<a class="btn btn-primary" asp-controller="PriceList" asp-action="BackTo" asp-route-backTo="#Model.BackTo">#localizer["zurück"]</a>
<a class="btn btn-primary" asp-controller="PriceList" asp-action="NewSurchargeFixPrice">#localizer["neuer Aufschlag"]</a>
<button class="btn btn-primary" type="submit">#localizer["speichern"]</button>
</div>
</form>
I change the input field to
< input formnovalidate="formnovalidate".../>
and now I can reach the breakpoint in my controller.

Razor Page and Bootstrap, no space between links

I don't know why after adding the if statement a margin/space between my action links disappears. I'm pretty sure that a HTML looks the same with or without #if (User.IsInRole("Admin")) (from the admin perspective). I'm using bootstrap 4.1.
<section id="sec5">
<div class="container pt-5">
<div class="table-responsive-sm mb-3">
<table class="table">
<tr>
<th>Name</th>
<th class="text-right">Action</th>
</tr>
#foreach (var u in Model)
{
<tr>
<td>#u.Name</td>
<td class="text-right">
#if (User.IsInRole("Admin"))
{
#Html.ActionLink("Edit", "Edit", new { id = u.SpecialityId }, new { #class = "btn btn-secondary" })
#Html.ActionLink("Delete", "Delete", new { id = u.SpecialityId }, new { #class = "btn btn-danger" })
}
</td>
</tr>
}
</table>
</div>
</div>
</section>
E:
https://jsfiddle.net/xoduf1sp/5/
In your example both the second link follows the first link immediately.
If i add a linebreak between them in the html the usual inline element gap appears.
Maybe your if clause does somehow elimitate whitespace/linebreak characters between the two links?
Was:
<a class="btn btn-secondary" href="#">Edit</a><a class="btn btn-danger" href="#">Delete</a>
Should be:
<a class="btn btn-secondary" href="#">Edit</a>
<a class="btn btn-danger" href="#">Delete</a>
See http://jsfiddle.net/xoduf1sp/7.

How to show and hide buttons with bootstrap and angularjs?

I have a table which contains some data and some buttons which changes according to response and user.
Here's the table.
<div class="form-group">
<div class="col-lg-12 col-md-9">
<table id="basic-datatables" class="table table-bordered" cellspacing="0" width="100">
<thead style="text-align:center">
<tr>
<th rowspan="1" colspan="1" style="width:100px; text-align:center">Employee ID</th>
<th rowspan="1" colspan="1" style="width:100px; text-align:center">Employe Name</th>
<th rowspan="1" colspan="1" style="width:100px; text-align:center">Email</th>
<th rowspan="1" colspan="1" style="width:100px; text-align:center">Department</th>
<th rowspan="1" colspan="1" style="width:100px; text-align:center">Date Created / Joined</th>
<th rowspan="1" colspan="1" style="width:110px; text-align:center">Actions</th>
</tr>
</thead>
<tbody style="text-align:match-parent">
<tr ng-repeat="data in details = (FilterDetails | limitTo:itemsPerPage:(currentPage-1)*itemsPerPage)">
<td style="text-align:center">{{data.Employee.Empid}}</td>
<td style="text-align:center">{{data.Employee.Fname}} {{data.Employee.Lname}}</td>
<td style="text-align:center">{{data.Employee.Email}}</td>
<td style="text-align:center">{{data.Department.DeptName}}</td>
<td style="text-align:center">{{data.Employee.Date_of_join | dateFormat}}</td>
<td style="text-align:center; width:100px">
<div>
<button type="submit" class="btn btn-success pad btn-sm" ng-click="Generate(data)">Generate</button>
<!--<button type="submit" class="btn btn-success pad btn-sm" ng-click="state = true" ng-hide="state">Generate</button>-->
<button type="submit" class="btn btn-warning btn-sm" ng-show="data.UserLogin.Status=='pending'">Pending</button>
<button type="submit" class="btn btn-default btn-sm" ng-show="data.UserLogin.Statuss=='pending'">Retry</button>
</div>
</td>
</tr>
</tbody>
</table>
<p ng-show="details.length == 0">No Users found.</p>
<div class="col-md-8 col-xs-12">
<uib-pagination total-items="totalEmployees" ng-model="currentPage" ng-change="pageChanged()" max-size="maxSize" boundary-links="true" class="pagination" items-per-page="itemsPerPage"></uib-pagination>
</div>
</div>
</div>
What I need to get done is that when the response comes from the JSON data the buttons have to change. Now according to this;
Generate button should show whendata.UserLogin.Status == ''(empty)
Pending button should show when data.UserLogin.Status == 'pending'
Retry button should show when data.UserLogin.Status == 'pending'
How do I achieve this. Help woud be appreciated.
You can use ng-show ng-hide or ng-if like below,
<button class="btn btn-default" ng-show="data.UserLogin.Status == ''">Generate </button>
or
<button class="btn btn-default" ng-hide="data.UserLogin.Status != ''">Generate </button>
or
<button class="btn btn-default" ng-if="data.UserLogin.Status == ''">Generate </button>
You should go for ng-if instead of ng-show or ng-hide. Because in case of ng-show or ng-hide based on the flag the content is loaded in the DOM. so if u try to change the value of flag by using web developer of browser u can be able to see the actual content. But if u go for ng-if, the content is loaded at runtime only when the condition is true. so whenever u want a quicker performance you can go for ng-show or ng-hide but if we want runtime behavior u should use ng-if.
You can write code as below..
<button class="btn btn-default" ng-show="data.UserLogin.Status == ''">Generate </button>
<button class="btn btn-default" ng-show="data.UserLogin.Status == 'pending'">Pending </button>
<button class="btn btn-default" ng-show="data.UserLogin.Status == 'pending'">Retry</button>
We can use ng-if,ng-show,ng-hide like
<button type="submit" class="btn btn-success pad btn-sm" ng-click="Generate(data)" ng-if="!data.UserLogin.Status">Generate</button> <button type="submit" class="btn btn-success pad btn-sm" ng-click="Pending (data)" ng-if="!data.UserLogin.Status">Pending </button>
use ng-if ,it is efficient
Use below code in the success function of the API. This code will run after you get the response and the DOM is created.
$scope.$evalAsync(function(){
$timeout(function() {
// Here set the scope variable and it will work in ng-show
}, 0); // wait...
});
Note: Do not forget to add $timeout in the controller.

React not ordering JSX elements correctly

I'm new to React.
Here is my code inside a React component:
for (var i = 0; i < fields.length; i++) {
rows.push(
<tr>
<td>...</td>
<td>...></td>
</tr>
)
}
return (
<tr>
<form className="updateForm" onSubmit={this.handleSubmit}>
<td>
<table>
{rows}
</table>
</td>
<td>
<button id={this.props.id} name="Update" type="button">Update</button>
<button id={this.props.id} name="Delete" type="button">Delete</button>
<button id={this.props.id} name="Add" type="button">Add</button>
</td>
</form>
</tr>
Here is the output HTML:
<tr data-reactid=".au4np63w8w.1.0.1.0.$0">
<form class="updateForm" data-reactid=".au4np63w8w.1.0.1.0.$0.0"></form>
<td data-reactid=".au4np63w8w.1.0.1.0.$0.0.0">
<table data-reactid=".au4np63w8w.1.0.1.0.$0.0.0.0">
<tbody>
...
</tbody>
</table>
</td>
<td data-reactid=".au4np63w8w.1.0.1.0.$0.0.1">
<button id="0" name="Update" type="button" data-reactid=".au4np63w8w.1.0.1.0.$0.0.1.0">Update</button>
<button id="0" name="Delete" type="button" data-reactid=".au4np63w8w.1.0.1.0.$0.0.1.1">Delete</button>
<button id="0" name="Add" type="button" data-reactid=".au4np63w8w.1.0.1.0.$0.0.1.2">Add</button>
</td>
</tr>
Notice that the form element that is supposed to include the table cells renders so that the table cells are outside of the form. I would expect that it should all be WYSIWYG. Am I doing something wrong or is it an actual bug? BTW, I'm using Babel with Webpack to parse JSX.
This is not a bug in React but rather the browser cleaning your erroneous semantics up.
A form element is not allowed as a direct child of a tr element. That's why your browser/React is outputting the HTML you see.
Paste below HTML in JSBin/Fiddle or the W3 validator and see the results
<table>
<tr>
<form>
<td>Hello!</td>
</form>
</tr>
</table>
A td can contain a form or a form can contain a table.

How to add browse button to glyphicon-picture in bootstrap

In my page I have a text area and it has glyphicon-picture's button and glyphicon-video's button, now I need to add browse button to these buttons, how can I do this?
Edit:
<table cellpadding="5px" cellspacing="5px" style="margin: auto; margin-top: 10px">
<tr>
<td class="design"><span class="glyphicon glyphicon-pencil" style="font-size: 18px;"></span></td>
<td class="design"><span class="glyphicon glyphicon-picture design-icon"></span></td>
<td class="design"><span class="glyphicon glyphicon-facetime-video design-icon"></span></td>
<td class="design"><span class="glyphicon glyphicon-link design-icon"></span></td>
<td class="design"><span class="glyphicon glyphicon-calendar design-icon"></span></td>
</tr>
</table>
now I just have this and I want to add browse button to glyphicon-picture and I dont know how do this.
You can add glyphicon image to a button ..Try the following code.Hope it helps
<button class="btn btn-success"><i class="icon-white icon-ok"></i>Elham Gdz</button>