Kendo aggregate client footer template plus sign throws an exception - kendo-ui

I want to calculate a grand total in my aggregate footer but this code isn't working for me.
Please help.
.ClientFooterTemplate("Grand total: #=kendo.toString(sum+sum, 'C')#");

This is expected as the plus sign is removed from the template using regex. In current case better approach would be calling external function where the calculation will be done.
.ClientFooterTemplate("Grand total: #=calculateAggregate(sum)#")
JavaScipt:
functio calculateAggregate(sum) {
return kendo.toString(sum + sum, 'C');
}

Related

IMPORTXML To Return a Value from dividendhistory.org

I want to return the value of "Yield:" from a series of stocks from a URL dividenhistory.org, for example HDIF into a Google sheet using IMPORTXML, where F7 represents the user supplied ticker.
=IMPORTXML("https://dividendhistory.org/payout/TSX/"&F7, "/html/body/div/div[2]/div[2]/p[4]")
The problem with the above is the yield value is not always located in the same paragraph, depending on the ticker. It also returns with the word "Yield:" as part of the value.
I believe I should be using the XPATH parameter which should find and return the yield value only, but I am lost. I am open to all suggestions!
I tried with a few of the tickers there, and this should work. For example:
=IMPORTXML("https://dividendhistory.org/payout/ctas/", "//p[contains(.,'Yield')]/text()")
Output:
Yield: 1.05%
Obviously, you can change 'ctas' for any user input.
Try this and see if it works on all tickers.
EDIT:
To get only the number 1.05, you need to split the result and output the 2nd part:
=index(split(IMPORTXML("https://dividendhistory.org/payout/ctas/", "//p[contains(.,'Yield')]/text()"), ": "),2)
Output:
0.0105

JQuery aproach to count elements before and after: always same value

I have a table with columns and below, an icon upon clicking, I can modify the table columns.
Now I want to count the columns before and after. I have a solution which works, where I call the the following before and after and then use the wrapped alias (via parseInt) to compare:
cy.get('body').then(($el) => {
// eslint-disable-next-line #typescript-eslint/no-unsafe-assignment
const countColsNr = $el.find('th[e2e-tag-header]').length;
cy.wrap(**to be named**).as(`${s}`);
});
This counts the actual columns and saves it in the variable to be named.
However, if I use a JQuery approach, it always gets the same column number, which is at the beginning of the test:
const beforetColsNr = Cypress.$('th[e2e-tag-header]').length;
log(beforetColsNr.toString());
... column handling code
... also tried with wait inbetween steps for debug
const afterColsNr = Cypress.$('th[e2e-tag-header]').length;
log(afterColsNr.toString());
Before number and after, are the same! When I look at the state of the browser (screenshot), I can see different columns amount at time of counting in after. This JQ-approach does not count properly the second time or uses the first value.
Is this something which is expected? Or is something I have to investigate?
cypress is asyncrhonous, so beforetColsNr and aftterColsNr are initialized at the same moment.
In the "cypress" mode in your first code block it works because of the usage of the .then().

Jmeter script for different orderlines

I have question on jmeter
we have different types of order lines like (3 ,5, 15) orders.
i need to create a script for different order lines.
please find the my approach in loadrunner, how can we do the same in jmeter
In loadrunner--> I have created different action with switch case
Action name :
OrderLine(trans, int orderline)
{
switch case
case 3:
requests for 3 order lines
case 5:
requests for 5 order lines
case 15:
requests for 15 order lines; break;
}
in another action, i will call OrderLine transaction
Action_03Lines()
{
Orderlines(OrderLines_03,3);
Orderlines(OrderLines_03,3);
Orderlines(OrderLines_03,3);
}
Action_05Lines()
{
Orderlines(OrderLines_05,5);
Orderlines(OrderLines_05,5);
Orderlines(OrderLines_05,5);
Orderlines(OrderLines_05,5);
Orderlines(OrderLines_05,5);
}
and i will call the actions on %ile bases.. like Action_03lines will run for 90% and Action_05 & Action_15 will execute with 5% each.
Use Switch_Controller as parent of each request with relevant number in switch value
Switch Value
The number (or name) of the subordinate element to be invoked.
In JMeter you have:
Test Fragment - to hold the reusable code
Module Controller - to refer the reusable code blocks where required
Loop Controller or While Controller - to iterate the block of code for desired number of times or while certain condition is (not) met

postman - how to generate random number in specific range?

I need to generate random number in specific range for postman.
I wonder if there is possible to generate it and to use it in variable in postman, from what I saw at postman site is:
{{$randomint }}
will give random number between 1-1000
and I already tried to do something like this:
{{$randomint(1,5)}}
to get number between 1-5 but postman didn't get this kind of option, so how to specify range for the random in postman?
You can just use Lodash for this as it's a built-in module:
pm.environment.set("random_number", _.random(1, 5))
Or just add the number 5 to the _.random() function and this will be a number from 0 to 5.
This worked for me:
In your Pre-request script define your variable with:
pm.globals.set('randomNumber', Math.floor(Math.random() * 5));
Then in your URL call your variable in the URL like so:
{{randomNumber}}
Hope this works for you.
A little late.
But none of the above answers worked for me.
I solved it by setting a variable in pre-request tab.
Example:
pm.collectionVariables.set ("randomNum", _.random (20,100));
Then use the variable name in the body of my request (like any other variable)
{
"number": {{randomNum}}
}
Finally, this generates a new number between the desired values in each request
Just use the modulo operation:
const num = pm.variables.replaceIn('{{$randomInt}}') % 5 + 1;
pm.environment.set("random_number", num);
// test
console.log(pm.variables.get('random_number'));

Output of getPaymentHtml() in Magento

I haven't been able to find where does the output of getPaymentHtml() comes from.
Its defined as:
public function getPaymentHtml() {
return $this->getChildHtml('payment_info');
}
I couldn't find out the template for payment_info block.
Basically I want to be able to retrieve credit card type and credit card number in the progress block of checkout.
How do I find out the method names? Something like $this->getCreditCardType()
Edit: OK! I understand that Magento figures out the payment method first which has their corresponding templates which are used to render output. But in progress.phtml of checkout, var_dump( $this instanceof Mage_Payment_Block_Info_Cc ); returns false, so how do I access that in current context?
The Progress block doen't have it's own template for Payment info. Mage_Checkout_Block_Onepage_Payment_Info block uses the selected Payment Method block to output html. Look at the Mage_Checkout_Block_Onepage_Payment_Info::_toHtml() method:
protected function _toHtml()
{
$html = '';
if ($block = $this->getChild($this->_getInfoBlockName())) {
$html = $block->toHtml();
}
return $html;
}
To find the actual template and block for the specific Payment method you use, you need to perform next steps:
First - get model alias for current payment method Mage::getStoreConfig('payment/'.$yourMethod.'/model') and instantiate it using Mage::getModel(alias)
then get block type using $model->getInfoBlockType() - so you'll be able to find the actual Block by it's type
For example for ccSave payment method the info block is Mage_Payment_Block_Info_Ccsave, and template for it is app\design\frontend\base\default\template\payment\info\default.phtml. You'll be able to find all data inside those.
Good luck ;)
For the sake of completeness, exact functions to fetch CC type and last 4 digits of CC number are:
echo Mage::getSingleton('checkout/session')->getQuote()->getPayment()->getCcType();
echo Mage::getSingleton('checkout/session')->getQuote()->getPayment()->getCcLast4();
The block class is declared in layout update XML; see the onepage checkout and multishipping directives from checkout.xml. The actual child block which is used depends on the payment model which is being used, but there is a common template that will be used unless overridden.
Example:
See the generic CC method model Mage_Payment_ModelMethod_Cc
From that see its info block Mage_Payent_Block_Info_Cc...
...which will lead you to the "base" payment info block Mage_Payment_Block_Info which sets a default template.

Resources