I currently have a grid with a column that has larger numbers (1000+).
My customer recently asked me to make that column have commas within those numbers. I know you can change the number into a string, however, I do some mathematical work as well with that column, so I would prefer not changing the number from an int to a string and then reverse it again.
The grid I'm using is a Telerik Extensions MVC grid.
Thanks.
You can use the Format() method, and pass your desired format to it. (but you have to test your format against the culture settings because formats are culture-dependent)
#(Html.Kendo().Grid<YourModel>().Name("YourGridName").Columns(columns =>
{
...
// this format puts group separator for large numbers
columns.Bound(p => p.LargeNumberField).Title("LargeNum").Format("{0:0,00}");
})
You can use
Format("{0:N0}")
only because I get error for negative number as my numbers are not always larger than 1000.
Warr's answer can be userful too.
How to add in KendoUI MVC Grid a thousand comma separator
Related
I'm trying to match a string of numbers (like 370488004) using the typical INDEX MATCH formula. Unfortunately, in one range the numbers are formatted as plain text, and in the other range they are formatted differently. Usually 'Automatic' or 'Number'. I want to avoid having to update the formatting of both ranges whenever the values get updated (usually via a paste from an outside source). Especially since it's not always going to be me doing the updating.
Is there a way I can write my INDEX MATCH formula so that it ignores the formatting of the values it's attempting to match?
The value returned by the INDEX formula can be in any format. Plain text, number, doesn't matter. The problem is the two values I'm matching are in different formats. I need a formula that ignores that their formatting.
Here's an example sheet:
https://docs.google.com/spreadsheets/d/1cwO7HGtwR4mRnAqcjxqr1qbhGwJHLjBKkp7-iwzkOqY/edit?usp=sharing
You can use VALUE or INT to force it into a number value, or if you want to keep it text use TEXT. Example would be:
=INDEX(VALUE(D1:E4),MATCH(G1,E1:E4,FALSE),1)
The numbers in column D are in fact text, but utilizing VALUE first for the range puts them all in number format. It is finding the value associated with "Green" written in G1. Without seeing a working example sheet this is the best solution I can offer.
UPDATE:
You can use VLOOKUP array with a static range (otherwise error), or QUERY to have the range infinite.
=ARRAYFORMULA(VLOOKUP(VALUE($G3:$G5),$B3:$C,2,FALSE))
=QUERY(FILTER($B3:$C,$B3:$B=VALUE($G3:$G)),"Select Col2")
For view purposes I am formatting the date values in my grid and that seems to be fine.
The problem is my column is also sortable and my custom date formatting is messing up the sorting. If I sort by real values from database, the sorting is fine but then I lose the ability of custom formatting the date for view purposes. So I wanted to see if there is a way to tell it format it like this but sort it some other way?
Here is how I format:
obj.Item.CustomFormattedDate = kendo.toString(kendo.parseDate(obj.Item.RealDbDate, 'yyyy-MM-ddTHH:mm:ss'), 'MM/dd/yyyy hh:mm tt');
and then in my column definitions I setting my column to that field CustomFormattedDate which is good for viewing but BAD for sorting. If I switch my field to be the actual RealDbDate values, then sorting becomes good but viewing becomes bad!
I'm doing exactly what you're looking for. I'm using the ASP.NET Core wrappers for Kendo and set up the column like this:
columns.Bound(p => p.ShipDate).Format("{0:g}");
Ship Date in the model is a DateTime, the sorting works, but then I can make that format string any of those listed here https://docs.telerik.com/kendo-ui/globalization/intl/dateformatting
I have a column called internal_code in my Customer model. Since some users may use it as alphanumeric and others as only numeric, I need to suggest a number to the user before confirmation, in the UI.
I'm using this code right now:
previous_number = Company.where(:company_id => self.company_id).maximum(:internal_code)
But this is not working as expected, given for some reason, sometimes it's returning "999" when the latest value is "1000", or in another example "2290" when the latest value "2291".
I've been digging in the official documentation on maximum and calculate for Active Record, but didn't found if it's not intended to work with String columns. Maybe it's just obvious, but I wanted to ask here before I confirm my thoughts.
If this is a text column you may be getting the ASCIIabetical "max" instead of the numerical max. "999" sorts after "2291".
You need a numerical column type (e.g. INT) in order to do numerical maximums.
This should be a simple migration to change the column type if those values are purely numerical and fit in a 32-bit or 64-bit integer.
The definitive solution I found:
# Note: the ORDER clause is the KEY. Length means biggest number, ::bytea means sort it alphanumerically
filtered_result = Company.where.not(:internal_code => [nil,'']).where(:company_id => self.company_id).order("length(internal_code) DESC, internal_code::bytea DESC").first
previous_number = filtered_result.internal_code.scan(/\d{2,5}/).last
This complexity is given because of the possible values the users can put in this field. E.g.
"ABD123"
AS2134FG
AS34SD2342
Hope it helps in similar issues. Thanks all.
I am trying to create an appropriate Format table property of a specific MS Access table in order to achieve the display style described below. For example purposes, let the table name be example and the field that I am trying to format be dollars
When example!dollars.Value is 567.98, I wish to display $0.567K. I also wish to display 1,000.42 as $1.000K.
In another table storing larger values, I use the Format property string $#,##0,\K; ($#,##0,"K)"[Red];"| < $1K |"; --, which successfully displays the amount in K dollars; however, any values less than $1K cannot be displayed. This is not acceptable due to the scale of the values in the example table.
The most intuitive solution is to use the string $0,000\K and specify the thousands separator as . instead of ,. However, I do not know how to do this.
Any advice will be greatly appreciated!
This works for me:
Kamount = Format(Amount/1000, "$0.000K")
So divide by 1000, then format as needed.
Use the Format property string $0\.000\K
I had a jqgrid with float numbers. I tried to get rid of the right side 0 and group the numbers, so those are now like (for example: "123,242"), and you know that the type of them are now String.
I want to sort theme like integer numbers in jqgrid.
what should I do?
for example a part of a column
after sort(asc) these strings are like
this:
1,959
1,965
1,989
10,235
100
100
...
Thanks in advance.
I believe you implemented the indexing and sorting according to jqGrid document. For example: http://www.trirand.net/forum/default.aspx?g=posts&t=254
I assume you retrieved data from database. If you’ve followed those already, moreover, you may need to CAST or CONVERT that particular database field from STRING or VARCHAR into INT or NUMERIC when you bind your SQL query.
jqGrid is powerful to do rest of things automatically.
You can zero-pad them (e.g. 00100 and 01959), sort them, and then remove the padding. Computer Programming 0101.