I'm trying to prevent a 'null' being displayed on the UI with this template:
template: '# if (PassExpiryDate !== null) {# #=kendo.toString(kendo.parseDate(PassExpiryDate), "dd-MMM-yy")# #} else {#   #}#'
Where the date is available, it shows a formatted date but it still shows a null as well.
Can someone pinpoint the issue with the client template?
Update
Tried another one but with no luck:
template: '#= typeof PassExpiryDate == "undefined" || PassExpiryDate == null ? "" : kendo.toString(kendo.parseDate(PassExpiryDate), "dd-MMM-yy") #'
What you need to do is do
... else { # <span></span> # } #
Related
Is there a way to remove the commas when using Currency pipe?
<div>{{balance | currency }}</div>
Output like this - $7,885,412.00
I want like this - $7885412.00
You can use Angular Inbuilt replace pipe.
<div> {{balance | currency | replace:',':''}}</div>
So, i just made a test app that worked.
generate a pipe using cli, as that will register it for you too with:
ng g p noComma
inside the no-comma.pipe.ts
replace the transform section with:
transform(value: number): string {
if (value !== undefined && value !== null) {
return value.toString().replace(/,/g, '');
} else {
return '';
}
}
then in your view,
{{ balance | currency | noComma }}
I want to print the address in the following order and I was able to do that. My problem is for some users some address fields are null then it is printing like this (1804 E Broadway, , 223344) and also I want divide the address in to lines.
<td>${addr1 }, ${addr2 }, ${postalCode }</td>
You can achieve your requirement is 3 ways:
1. JSP EL
<!-- here I am using adjacent EL expression because string concat will not work here and if we put EL expression in new line one space is adding-->
<td>${addr1 }${empty addr1? '': ','}
${addr2 }${empty addr2? '': ','}
${postalCode }</td>
2. JSTL
<c:if test="${not empty addr1}">
${addr1},
</c:if>
3. Using java code in JSP
I will not recommend this method because writing java code in JSP is not encouraged.
<%= (addr1 != null && addr1 !="") ? addr1 +",": "" %>
You can use a ternary operator in your JSP like this:
<%= (field != null && field !="") ? field +",": "" %>
How do you parse csv files that have different header names?
I was trying to do it somewhat like this in meteor method:
parseUpload(data){
check(...)
for(let i=0;i<data.length;i++){
let item = data[i]
let thing = {
name: item.name || item.itemname || item.something,
category: item.category
}
items.insert(thing);
}
but it was always taking the first param (item.name) and as it was empty, the method couldn't be executed. How do i do OR statement to bind name to doc.namesArray so uploaded file can use aliases for column names?
also, i have noticed that when you make spreadsheet not starting from 1A, it creates empty lines/rows in csv document. papaparse still expects first column to be "name" and everything stops working again (untill i recreate csv file so it starts with actual values).
If you try to paste this code into the console window in your browser:
item={name:' ',itemname:"itemname",something:"something"}
item.name || item.itemname || item.something
You'll get this:
" "
Similarly with this:
item={name:'',itemname:"itemname",something:"something"}
item.name || item.itemname || item.something
You get
"itemname"
So if item.name is an empty string, or missing, then you get item.itemname returned
So the code is ok, your data must not be as you expect. Try putting a console.log(item) in and see what you get, or set a breakpoint and inspect it.
I'm getting started with Jinja by converting my Django templates. Let's say I have a variable that represents a dollar value. So if I want to format it to two decimal places, I would do this:
{{"%.2f" | format(my_dollar_var)}}
But what if my_dollar_var is None? In that case, I'd like to show something else (like a question mark or a dash -- but not a zero).
I use a customer Currency filter:
def Currency(value):
if(value == None):
return "???"
else:
return "${:,.2f}".format(float(value))
jinja2.filters.FILTERS['Currency'] = Currency
Then just use:
{{ PRICE | Currency }}
Hope this helps!
I have this field in my database of the type which hold HTML. By default it has the value:
<html xmlns='http://www.w3.org/1999/xhtml'> <head></head> <body></body> </html>
Now I need to check if a user has added something to that field and display it, or else do not display this field at all.
I have tried things like:
#if(String.IsNullOrEmpty(#Html.Raw(#Product.Specificity)) == false ) { blah }
But that throws an error.
I can not use
#if(String.IsNullOrEmpty(#Product.Specificity) == false ) { blah }
because the field is not completely empty; it holds the HTML above...
It's better to save only user input in the database and remove extra "wrapping" tags from it. But if you can't to do it you can simple compare your field value with "empty" value (you can save it somewhere as constant):
#if (#Product.Specificity != Constants.EmptySpecificity) { ... }