I have this code that is getting data from a cell in a table
<div class="p-s-header">TITLE</div>
<div class="p-content">
<div class="row">
<div class="col-md-12 col-xs-12 col-sm-12">
<span di="76" ></span><br />
<span di="77" ></span><br />
</div>
</div>
</div>
This is producing:
TITLE
(data in cell 76)
(DATA in cell 77)
Now, data in cell 77 is a a link that is too long for the space, so I want to add the work "Click here" (hyperlinked) instead of showing the link.
So I wanted to change code, so output looks like:
TITLE
(data in cell 76)
Click here
"Click here" shoudl be built with the data in cell 77. I didn't code this but it seems the code to get the data from that cell is:
How would I build it?
I tried a few options, but nothing seems to work:
For example something like this:
<a href=<span di="77" ></span>Link</a><br />
thanks for your help
Try this, I hope this will encourage you on studying further how HTML and JS work together. (PHP is too advanced right now).
Change your code for this:
<div class="p-s-header">TITLE</div>
<div class="p-content">
<div class="row">
<div class="col-md-12 col-xs-12 col-sm-12">
<span id="cell76" ></span><br />
<span id="cell77" >http://www.google.com</span><br />
</div>
</div>
</div>
The attribute di doesn't exist, it is id and id's cannot start with numbers or be numbers
At the bottom of the code that you added write the following:
<script>
var link = document.getElementById('cell77').innerHTML;
document.write(''+link+'');
</script>
Here is the jsfiddle
https://jsfiddle.net/cz1Ltw3x/1/
Related
with a custom module, I have added the two fields header and footer to every res.company object. These are fields of the type binary.
I now want to display them in my document layout in qweb.
Unfortunately, odoo tells me
'base.document.layout' object has no attribute 'header'
This is what my layout looks like
<?xml version="1.0"?>
<t t-name="web.external_layout_boxed">
<div t-attf-class="header o_company_#{company.id}_layout" t-att-style="report_header_style">
<div class="o_boxed_header">
<div class="row mb8">
<div class="col-6">
<!--HERE--> <img t-if="company.logo" t-att-src="image_data_uri(company.header)" alt="brief_header"/>
</div>
<div class="col-6 text-right mb4">
<h4 class="mt0" t-field="company.report_header"/>
<div name="company_address" class="float-right mb4">
<span class="company_address" t-field="company.partner_id" t-options="{"widget": "contact", "fields": ["address", "name"], "no_marker": true}"/>
</div>
</div>
</div>
</div>
</div>
<div t-attf-class="article o_report_layout_boxed o_company_#{company.id}_layout" t-att-data-oe-model="o and o._name" t-att-data-oe-id="o and o.id" t-att-data-oe-lang="o and o.env.context.get('lang')">
<div class="pt-5">
<t t-call="web.address_layout"/>
</div>
<t t-raw="0"/>
</div>
<img t-if="company.logo" t-att-src="image_data_uri(company.footer)" alt="brief_footer"/>
</t>
as you can see I am trying to access the header with company.header
the pictures appended show you that the fields exist on the type.
What am I doing wrong? How can I correctly display the uploaded images in the external_layout_boxed?
When rendering the document, the company variable is set to wizard object not to the user company. Odoo will try to access header and footer in base.document.layout model.
To fix that issue, alter the document layout model like following:
class BaseDocumentLayout(models.TransientModel):
_inherit = 'base.document.layout'
header = fields.Binary(related="company_id.header")
footer = fields.Binary(related="company_id.footer")
You can find an example in l10n_de module where they created a new report layout and altered base.document.layout to use new fields like street, city or bank_ids
I'm working with PrimeNg picklist and here is what i have:
The focus is on the first row, don't mind the other rows not having the radio button (it's uncompleted testdata).
What i'm trying to achieve is that when you click on the first option 'Good:Stock', the little dropdown to the right with A1 appears. When you select 'Bad', it disappears.
The problem now is that when i select 'Good' for one item, the dropdown will appear for every record in the loop.
I want it to appear only for the item where i selected the radiobutton.
All help is welcome! Ask away if you need more code but i don't think the .ts file matters for now.
Here is what the code looks like:
<label for="productGroup">Select product</label>
<div class="form-group" id="productGroup">
<div class="row">
<div class="col">
<p-pickList [source]="products"
(onMoveToTarget)="onMoveToTarget()"
[target]="selectedProducts" sourceHeader="Available" targetHeader="Selected"
[responsive]="true" filterBy="description,productNumber"
dragdrop="true" dragdropScope="products" [showTargetControls]="false" [showSourceControls]="false"
sourceFilterPlaceholder="Search product in Available"
targetFilterPlaceholder="Search product in Selected"
[sourceStyle]="{'height':'33vh'}" [targetStyle]="{'height':'33vh'}">
<ng-template let-product pTemplate="item">
<div id="product" class="row ui-helper-clearfix">
<div class="col-1 padding-0 brighten">
<img (mouseover)="getProductImage(product)"
[escape]="false"
pTooltip='<img style="max-height: 100%; max-width: 100%" src="{{base64String}}">'
tooltipPosition="right"
src="assets/eye-icon.png" style="max-width: 100%; width: 80%;">
</div>
<div class="col-4">
<div class="row">{{product.description}}</div>
<br>
<div class="row">{{product.productNumber}}</div>
</div>
<div class="col-4" *ngIf="inbound && product.goodLabel && product.badLabelInWarranty &&!hqAdmin&&!carStock">
<div class="row">
<p-radioButton (onClick)="toggleProjects(true, product.id)" name="{{product.productNumber}}"
label="Good: {{product.goodLabel.name}}"
[value]="product.goodLabel" [(ngModel)]="product.quality">
</p-radioButton>
<p-radioButton name="{{product.productNumber}}"
label="Bad: {{product.badLabelInWarranty.name}}/{{product.badLabelOutOfWarranty.name}}"
[value]="product.badLabelInWarranty" [(ngModel)]="product.quality"
(onClick)="toggleProjects(false, product.id)">
</p-radioButton>
</div>
</div>
<div class="col-2 nopadding" *ngIf="goodSelected">
<p-dropdown id="dropdownInput"
[autoWidth]="false"
[options]="projectLabelSelectItems">
</p-dropdown>
</div>
</ng-template>
</p-pickList>
</div>
</div>
</div>
What is happening in you case suppose lets take an example you have 10 rows and your are maintaining one single variable for all row so what happen when the value of that flag become true or false drop-down from all the rows will show or hide.
So what is suggest in the collection take one property extra for this drop-down column.
<div class="col-2 nopadding" *ngIf="goodSelected">
<p-dropdown id="dropdownInput"
[autoWidth]="false"
[options]="projectLabelSelectItems">
</p-dropdown>
</div>
Here goodSelected is single variable insted of add one vriable in property
<div class="col-2 nopadding" *ngIf="product.goodSelected">
<p-dropdown id="dropdownInput"
[autoWidth]="false"
[options]="projectLabelSelectItems">
</p-dropdown>
</div>
And on toggle make goodSelected selected value true or false of selected row only.
Actually I am using pagination in web page,i am putting one condition ng-if="id !== 0" if this code is true then it will hide some portion if its false its showing that portion.My problem is if condition is false then it showing that portion but pagination is not working when i am clicking on next its not going to the word.but if i am using the same condition in ng-show its working fine pagination is also working.Please help me whats going on there i am unable to understand.
Here is my code..
<div class="orphan-navigation col-md-12" ng-show="totalOrphans !== 0">
<div class="col-md-2 pull-left orphan-count">
{{id}} / {{totalOrphans}}
</div>
<div class="navigation-button-container pull-right">
<uib-pagination total-items="totalOrphans" ng-model="id" max-size="limitPages" ng-change="orphanChanged()" items-per-page="1">
</uib-pagination>
</div>
</div>
<div class="col-md-12 orphan-text-label" ng-show="totalOrphans !== 0">
<div class="col-sm-3 label label-default pull-left orphan-key">Un-Annotated word</div>
<div class="col-xs-4 small-left-margin label orphan-key searchText">{{orphanData.orphan.attributes.text}}</div>
</div>
in above code i have used ng-show="totalOrphans !== 0" for ng-show my pagination is working fine when i am clicking in next button its highlighting other words.thats i want result.
but if i used ng-if instead of ng-show my pagination is not working,its not highlighting next word when i am clicking on next.
here i am attaching image of my web page.
if someone has still not understand my question please comment here ,i will try to clarify you thanks in advance,
ng-if will create it's own scope. Also uib-pagination creates it's own scope and probably use its parent scope to create your pagination. Now if the ng-if has it's own scope uib-pagination can't use the scope paramater from you controller.
For this reason there is the ControllerAs Syntax.
To use it you need to define it in ng-controller like: ng-controller="AppCtrl as vm".
Inside your controller you need to define 'vm' with 'this':
app.controller('AppCtrl', [function() {
var vm = this
vm.id = 5;
}]);
Now you can use the id inside the HTML like this:
<div ng-controller="AppCtrl as vm">
<span>{{vm.id}}</span>
</div>
As an example your code with ng-if that you provided need to look like this:
<div class="orphan-navigation col-md-12" ng-if="vm.totalOrphans !== 0">
<div class="col-md-2 pull-left orphan-count">
{{vm.id}} / {{vm.totalOrphans}}
</div>
<div class="navigation-button-container pull-right">
<uib-pagination total-items="vm.totalOrphans" ng-model="vm.id" max-size="vm.limitPages" ng-change="vm.orphanChanged()" items-per-page="1">
</uib-pagination>
</div>
</div>
<div class="col-md-12 orphan-text-label" ng-if="vm.totalOrphans !== 0">
<div class="col-sm-3 label label-default pull-left orphan-key">Un-Annotated word</div>
<div class="col-xs-4 small-left-margin label orphan-key searchText">{{vm.orphanData.orphan.attributes.text}}</div>
</div>
Sorry for the question title. I really didn't know how to describe it best in a short sentence.
Basically I want to loop through each of my images and display them. However when doing the front end I did this:
<div class="row">
<div class="col-sm-4">
<img .../>
</div>
<div class="col-sm-4">
<img .../>
</div>
<div class="col-sm-4">
<img .../>
</div>
</div>
<div class="row">
<div class="col-sm-4">
<img .../>
</div>
<div class="col-sm-4">
<img .../>
</div>
<div class="col-sm-4">
<img .../>
</div>
</div>
Because there can only be 3 columns in a row for my design this worked fine. However now if i want to do this in php i have to kind of check the $count of the loop. If its a multiple of 3 display
<div class="row">
and if its a multiple of 3 + 1 then show
</div>
to close the row.
IS there any way I can make the mark up look the same as the example above but using this html below:
<div class="row">
<div class="col-sm-4">
<img .../>
</div>
<div class="col-sm-4">
<img .../>
</div>
<div class="col-sm-4">
<img .../>
</div>
<div class="col-sm-4">
<img .../>
</div>
<div class="col-sm-4">
<img .../>
</div>
<div class="col-sm-4">
<img .../>
</div>
</div>
Its just making my mark up look very messy. Is there a better way in bootstrap to do this without using php at all?
Thanks
You'll want to include conditions in your PHP loop so that PHP knows when to add in the row.
Below, I've laid out an untested set of PHP code that will hopefully explain where you're going wrong.
<?php
$images = array(...);
$images_per_row = 3;
// Here is where we determine how the images
// should be divided into the rows.
$total_images = count($images);
$total_rows = ceil($total_images / $images_per_row);
// Loop through each `row`
for ($row=0; $row<$total_rows; $row++)
{
// Open the `row`
echo '<div class="row">';
// We have an `offset` to avoid displaying the same image
// multiple times in the loop.
$offset = $row * $images_per_row;
// Loop through each `col-sm-4` and `img`
for ($i=0; $i<$images_per_row; $i++)
{
echo '<div class="col-sm-4">';
echo "<img src='{$images[$offset + $i]}' />";
echo '</div>';
}
// Closing the `row`
echo '</div>';
}
There are countless ways to do this. You can even do it all within a single loop if you use proper conditions within the loop.
The point is, you need a way of telling PHP "Hey, we need to divide all of this into thirds or we're never going to get anywhere with this."
Side note, PHP + HTML is a very ugly marriage. Please avoid it at all costs (unless you only have 10 minutes and you're trying to help someone on Stack Overflow).
Below I have a for-each loop using knockout.js.
<div data-bind="foreach:Stuff">
<div class="row">
<span data-bind="text: $data.name"></span>
</div>
</div>
I need to have the HTML Element with an id or name or something that reflects a unique value related to the $data.name value, as another method runs asynchronously, and needs to know which HTML element to update.
Ideally, it would look something like this, I guess:
<div data-bind="foreach:Stuff">
<div class="row">
<span id="data-bind='text: $data.name'" data-bind="text: $data.name"></span>
</div>
</div>
I have found a knockout syntax that applies values during runtime to specified attributes:
<div data-bind="foreach:Stuff">
<div class="row">
<span data-bind="attr: { id: $data.name}"></span>
</div>
</div>
Are you looking for this
<div data-bind="foreach:Stuff">
<div class="row">
<span data-bind="text: $data.name,attr:{id:$data.name}'"></span>
</div>
</div>
Here name is a observable i believe when ever there is change in name in stuff it will automatically updates its value & attr:{id}just to give a dynamic id to element using available bindings .