Hello there, i seem to be having a problem with getting a currency filter to work, i am trying to truncate any number past the decimal point. so if i have $3,456.04 , it
should be $3,456. However, after i add the filter function, what is displayed is 3456.
Here is the index.cshtml
columns.Bound(e => e.EstimatedGrantedCost).Title(
"Est.<br>Granted<br>Cost"
).Width(23).HeaderHtmlAttributes(
new
{ style =
"text-align:right; font-weight:normal; font-size:80%"
}).HtmlAttributes(
new
{ @style =
"text-align:right; font-weight: normal; font-size:80%"
}).Filterable(x => x.UI(
"CurrencyFilter"
));
function
CurrencyFilter(e) {
//console.log("this is what was passed in:",e)
$(e).kendoNumericTextBox({format:
"c0"
});
}
thanks for your help.
9 Answers, 1 is accepted
The provided code will work only if the filter is in mode menu. If the filter is in mode row the filter widget have to configured as follows:
.Filterable(x=> x.Cell(y=> y.Template(
"currencyFilter"
));
function
currencyFilter(args) {
args.element.kendoNumericTextBox({
format:
"c0"
});
}
I have assembled small sample (currency-filter.zip) which illustrates both solutions.
Regards,
Georgi
Progress Telerik
Excuse me but I am not sure that I understand you. Could you please send me a sample with the issue and what you want to achieve, so I can provide you with suitable solution for your exact case.
Based on the provided information I assume that the expected result is to format the value inside the EstimatedGrantedCost column. Please correct me if I am wrong.
As you have mentioned, in order to format the column possible solution is to use the Format property..
e.g
columns.Bound(e => e.EstimatedGrantedCost).Format("{0:c}")
Is there a reason to want to use another configuration?
Regards,
Georgi
Progress Telerik
Hello Georgi.
Originally, i was using
columns.Bound(e => e.EstimatedGrantedCost).Format("{0:c}") to format the column value. Which resulted in values like $3,456.04, $4,556.00. Thats all well and good. The end-user tests the code and say they don't want any decimals. So this $3,456.04 , should be $3,456 and $4,556.00 should be $4,556. That is what i am trying to achieve.
To achieve the desired result, use format like:
columns.Bound(e => e.EstimatedGrantedCost).Format("{0:c0}")
More information about the number formats is available in this article:
I hope this helps.
Regards,
Preslav
Progress Telerik
Hi this is just what I needed to see.
Only this shows up with dollar sign when I want the British pound sign.
How can I make sure this shows in GBP?
Many thanks.
Hello Avrohom,
You will have to set the culture to British. Include the following script:
<script src="https://kendo.cdn.telerik.com/2020.2.513/js/cultures/kendo.culture.en-GB.min.js"></script>
And set the culture to en-GB before the initialization of the widgets:
<script type="text/javascript">
//set current to the "en-GB" culture script
kendo.culture("en-GB");
</script>
Regards,
Georgi
Progress Telerik
Our thoughts here at Progress are with those affected by the outbreak.