i am trying to display element only when the selling price is bigger than 0
this is my code
.basket-sidebar-right-body-basket-why-not-try
.item-grid-item(dynamic-position, data-rv-each-item='model:suggested', data-rv-on-click='view.attemptToAddItemToCart')
.item-title(data-rv-text='item.WebTitle | startCase')
.item-image(focusable)
img(focusable,data-rv-src='item.ImageUrl', onerror='this.src = "http://placehold.it/237x140";')
.why-not-try-text= strings.whyNotTry
.why-not-try-price
span.currency-symbol £
span.price(data-rv-text='item.SellingPrice | asCurrency')
i am trying to display the why not try price only when item.sellingPrice is bigger than 0
anyone know how i can do that
?
Related
In my Angular App, I have a requirement to display total number of rows on current page in pagination section. But currently Devextreme grid row count returns total row count irrespective of page.
Below is my code :-
<dxo-paging [pageSize]="5"> </dxo-paging>
<dxo-pager
[visible]="true"
[allowedPageSizes]="allowedPageSizes"
[displayMode]="displayMode"
[showPageSizeSelector]="showPageSizeSelector"
[showInfo]="true"
infoText="Displaying {0} - {2} of {1} "
[showNavigationButtons]="showNavButtons"
>
</dxo-pager>
Below screenshot :-
Now i have only 5 rows in the grid but it shows 11 which is the total row count which i have received from database. Please advise.
If i understand correctly, you want to show 1-5 on the first page, 6-10 on the second page and so on. You can achieve that by binding a function to the [infoText] property and customize the text output. This is not found in the official documentation but it works.
HTML:
<dxo-paging [pageSize]="5"> </dxo-paging>
<dxo-pager
[visible]="true"
[allowedPageSizes]="allowedPageSizes"
[displayMode]="displayMode"
[showPageSizeSelector]="showPageSizeSelector"
[showInfo]="true"
[infoText]="infoText"
[showNavigationButtons]="showNavButtons">
</dxo-pager>
JS/TS:
infoText(currentPageNumber, totalPageCount, totalRowCount) {
const myPageSize = 5; // use global variable instead and bind it to dxo-paging
const from = +currentPageNumber * myPageSize - (myPageSize - 1);
const to = +currentPageNumber * myPageSize;
return `Displaying ${from}-${to}`;
}
I'm using Splunk version 7.0.1 and I'm trying to highlight my table cell colors based off of two other fields. Splunk has a sample to do this in Javascript that uses hardcoded values, but I need the values based off of a different field. I have the script working, but it randomly highlights some cells in the wrong color. I can't seem to figure out why.
The "Average Response Time" should be:
Red if the value is greater than or equal to the Threshold
Amber if the value is greater than or equal to the Objective but less than the Threshold
Green if the value is less than the Objective
My Table:
Transaction Count "Average Response Time" Objective Threshold
A/P - Close Module - FM1 1 7.52 2.00 6.00 **<-Colored Red and correctly**
...
A/P - Diagnosis- Run Search - FM1 2 4.01 100.00 100.00 **<- Colored Amber incorrectly**
Here is the dashboard source of the table:
<table id="response_time_highlight">
<title>NOTE: An Objective and/or Threshold of 100 indicates that an Objective and/or Threshold have not been identified for this particular transaction type.</title>
<search>
<query>index=arm sourcetype="arm:transaction" region="$region$" sitename="$sitename$" transaction_status IN ( $transaction_status$ ) username IN ( $username$ ) workstation_name IN ( $workstation_name$ ) transaction_name IN ( $transaction_name$ )
| stats count avg(response_time) AS response_time BY transaction_name objective threshold
| eval threshold=round(threshold,2)
| eval objective=round(objective,2)
| eval response_time=round(response_time,2)
| fields transaction_name count response_time objective threshold
| rename response_time AS "Average Response Time" transaction_name AS "Transaction Type" objective as Objective threshold as Threshold count as "Transaction Count"
| sort +transaction_name</query>
<earliest>$search_time.earliest$</earliest>
<latest>$search_time.latest$</latest>
<sampleRatio>1</sampleRatio>
</search>
<option name="count">20</option>
<option name="dataOverlayMode">none</option>
<option name="drilldown">none</option>
<option name="percentagesRow">false</option>
<option name="refresh.display">progressbar</option>
<option name="rowNumbers">true</option>
<option name="totalsRow">false</option>
<option name="wrap">true</option>
</table>
Here is the Javascript code (modified version of the dashboard examples one):
require([
'underscore',
'jquery',
'splunkjs/mvc',
'splunkjs/mvc/tableview',
'splunkjs/mvc/simplexml/ready!'
], function (_, $, mvc, TableView) {
var objective_value;
var threshold_value;
// Row Coloring Example with custom, client-side range interpretation
var CustomRangeRenderer = TableView.BaseCellRenderer.extend({
canRender: function (cell) {
// Enable this custom cell renderer for response_time field
return _(['Average Response Time', 'Objective', 'Threshold']).contains(cell.field);
},
render: function ($td, cell) {
// Add a class to the cell based on the returned value
var value = parseFloat(cell.value);
if (cell.field === 'Objective') {
objective_value = value;
}
if (cell.field === 'Threshold') {
threshold_value = value;
}
// Apply interpretation for number of historical searches
if (cell.field === 'Average Response Time') {
if (value >= threshold_value) {
$td.addClass('range-cell').addClass('range-severe');
}
else if (value >= objective_value) {
$td.addClass('range-cell').addClass('range-elevated');
}
else if (value < objective_value) {
$td.addClass('range-cell').addClass('range-low');
}
}
// Update the cell content
$td.text(value.toFixed(2)).addClass('numeric');
}
});
mvc.Components.get('response_time_highlight').getVisualization(function (tableView) {
// Add custom cell renderer, the table will re-render automatically.
tableView.addCellRenderer(new CustomRangeRenderer());
});
});
EDIT: Added a console.log to the javascript showing the output of each field. Noticed that the first row showing as undefined, and pushing the correct numbers down to the next row. Here is the output:
0 undefined undefined
8.64 100 100
7.52 2 6
0 2 6
7.52 2 6
1.11 10 25
2.28 2 6
2.92 2 6
I have this dynamic link.
Every 10 minutes refresh new data from weather station.
I want to sent this data in mysql using php or javascript.
The html link have follow result:
imerominia="26/08/16";
ora="20:22";
sunriseTime=" 06:48";
sunsetTime="20:08";
ForecastStr=" Increasing clouds with little temperature change. Precipitation possible within 24 to 48 hrs.";
tempUnit="°C";
outsideTemp="27.3";
hiOutsideTemp="31.6";
hiOutsideTempAT="18:01";
lowOutsideTemp="20.8";
lowOutsideTempAT="00:32";
hiMonthlyOutsideTemp="36.7";
lowMonthlyOutsideTemp="13.4";
hiYearlyOutsideTemp="38.6";
lowYearlyOutsideTemp="-8.9";
humUnit="% ";
outsideHumidity="39";
hiHumidity="78";
hiHumidityAT=" 00:31";
lowHumidity="32";
lowHumidityAT="12:02";
hiMonthlyHumidity="94";
lowMonthlyHumidity="27";
hiYearlyHumidity="98";
lowYearlyHumidity="20";
outsideDewPt="12.2";
hiDewpoint="17.2";
hiDewpointAT="00:37";
lowDewpoint="10.6";
lowDewpointAT="05:44";
hiMonthlyDewpoint="22.8";
lowMonthlyDewpoint="10.0";
hiYearlyDewpoint="25.0";
lowYearlyDewpoint="-12.2";
windUnit="km/hr";
windSpeed="11.3";
wind10Avg="4.8";
hiWindSpeed="25.7";
hiWindSpeedAT="06:04";
hiMonthlyWindSpeed="53.1";
hiYearlyWindSpeed="61.2";
windDirection="EbS";
moires="96°";
windChill="27.3";
lowWindchill="20.6";
lowWindchillAT="00:32";
lowMonthlyWindchill="13.3";
lowYearlyWindchill="-9.4";
outsideHeatIndex="27.3";
hiHeatindex="31.7";
hiHeatindexAT="18:11";
hiMonthlyHeatindex="42.2";
hiYearlyHeatindex="45.0";
barUnit="hPa";
barometer="1016.7";
BarTrend="Rising Slowly";
hiBarometer="1019.3";
hiBarometerAT=" 09:07";
lowBarometer="1015.6";
lowBarometerAT=" 17:19";
lowMonthlyBarometer="1007.2";
hiMonthlyBarometer="1023.5";
lowYearlyBarometer="993.7";
hiYearlyBarometer="1037.6";
rainUnit="mm";
dailyRain="0.0";
stormRain="0.0";
monthlyRain="16.0";
totalRain="307.6";
rateUnit="mm/hr";
rainRate="0.0";
hiRainRate="0.0";
hiRainRateAT=" n/a";
hiMonthlyRainRate="36.6";
hiYearlyRainRate="1645.8";
solarUnit="W/m²";
solarRad="n/a";
hiSolarRad="0";
hiSolarRadAT="n/a";
hiMonthlySolarRad="0";
hiYearlySolarRad="0";
uvUnit="index";
uv="0.0";
hiUV="0.0";
hiUVAT="n/a";
hiMonthlyUV="0.0";
hiYearlyUV="0.0";
I try some tricks but I can't find the solution.
How can this data insert to mysql database auto every 10 minutes or 1 hour or ... etc?
I want to make Total field in HTML table always listen if any changes on Qty/Price/Disc field (see below). So Total field always updated.
Id | Product | Qty | Price | Disc | Total
1 | A | 1 | 2 | 0 | 2
2 | B | 2 | 10 | 10 | 18
...
Here's the HTML : http://jsfiddle.net/ao6t2axs/
How to do this using javascript/jQuery?
Thanks in advance
Have updated your jsfiddle with a working solution
http://jsfiddle.net/5bym3jq5/
Code is
$('#table').on('change', 'input', function () {
var row = $(this).closest('tr');
var total = 0;
$('input', row).each(function() {
total += Number($(this).val());
});
$('.total', row).text(total);
});
Basically watch for any time an input inside the table fires a change event, find the row that that input is a part of, then update the total value for that row.
I am using angular js in PHP .. here is my angular js
<div ng-repeat="friend in friends | filter:query | filter:query2" >
<?php
$first_number = '{{friend.qty}}';
$second_number = '{{friend.price}}';
echo $first_number; echo '<br/>';echo $second_number;echo '<br/>';
$sum_total = $second_number * $first_number;
print ($sum_total);
?>
The Output is coming as
200
10
0
the value stored in {{friend.qty}} is displaying as 200 and value stored in {{friend.price}} is displaying as 10
i am not understanding why the output is zero that is $second_number * $first_number;