formatting

Access row data in jqGrid custom formatter

*爱你&永不变心* 提交于 2019-12-18 05:01:52
问题 We have a grid with datatype json. We have the following custom formatter: function opsFormatter (cellvalue, options, rowObject){ '<a title=MA href=javascript:showDialog(' + rowObject[5] + ')>MA<a>' + '  '; } Instead of rowObject[5] is there any object notation where we can specify the actual column name ("account")? Ie: rowObject.account . This is the grid definition: $("#grid-pos").jqGrid({ colNames:['Product', 'Type','Expiry', 'Put Call', 'Strike', 'Account','Long','Short', 'Open Qty',

NSDate expressed in different time zones, i.e. local time zone (GMT-400) to PST

耗尽温柔 提交于 2019-12-18 04:24:13
问题 I know how to use NSTimeZone to derive the offset for the current time in another time zone. NSDate always returns relative to GMT, so how do I derive a string with the proper time zone information? i.e. I take the current time where I am (in EST) and using NSTimeZone end up subtracting the 3 hours necessary to represent the time in PST. But all I've done is subtract 3 hours from the time which is still represented relative to my time zone. How do I get NSDateFormatter to spit out the time

Java: Currency to Locale Mapping Possible?

拈花ヽ惹草 提交于 2019-12-18 03:53:28
问题 I have a value stored in a DB correlating to a monetary amount, say 10.0. I also have access to the Currency/CurrencyCode. How can I use NumberFormat/DecimalFormat/(other?) to format when I don't know the Locale? According to the docs it will pick a default locale which won't work with a foreign Currency. 回答1: The correct behavior, generally speaking, is to format the amount in the User's preferred locale, not the currency's typical locale. On the client side, you'll have the user's

Formatting Large Numbers with .NET

回眸只為那壹抹淺笑 提交于 2019-12-18 03:36:08
问题 I have a requirement to format large numbers like 4,316,000 as "4.3m". How can I do this in C#? 回答1: You can use Log10 to determine the correct break. Something like this could work: double number = 4316000; int mag = (int)(Math.Floor(Math.Log10(number))/3); // Truncates to 6, divides to 2 double divisor = Math.Pow(10, mag*3); double shortNumber = number / divisor; string suffix; switch(mag) { case 0: suffix = string.Empty; break; case 1: suffix = "k"; break; case 2: suffix = "m"; break; case

Cannot remove block comment in Eclipse after formatting

冷暖自知 提交于 2019-12-18 03:03:47
问题 Eclipse's automatic formatter changes block comments such that the Source > Remove Block Comment does not completely remove the block comment. Source > Add Block Comment adds the start and end of the clock comment to the lines of code, but after running the Formatter (Ctrl + Shift + F), it wraps the lines of code and adds an asterisk to the start of each line. When I try to remove the block comment with Source > Remove Block Comment, the start and end of the block comment is removed, but the

IntelliJ collapsing single line methods

点点圈 提交于 2019-12-18 03:03:06
问题 Since I've updated my version of intelliJ (14.x to 15.x) it has started automatically collapsing single line methods in the Java editor: Previous version: public void setContext(SecurityContext context) { this.context = context; } Latest version: public void setContext(SecurityContext context) { this.context = context; } Is there a way to prevent this? I find the original version much easier on the eyes! Thanks. 回答1: Open 'Settings' from the File menu. Under 'Editor' -> 'General' -> 'Code

Fixed width number formatting python 3

为君一笑 提交于 2019-12-18 01:18:08
问题 How do I get an integer to fill 0's to a fixed width in python 3.2 using the format attribute? Example: a = 1 print('{0:3}'.format(a)} gives ' 1' instead of '001' I want. In python 2.x, I know that this can be done using print "%03d" % number. I checked the python 3 string documentation but wasn't able to get this. http://docs.python.org/release/3.2/library/string.html#format-specification-mini-language Thanks. 回答1: Prefix the width with a 0 : >>> '{0:03}'.format(1) '001' Also, you don't need

Format a javascript number with a Metric Prefix like 1.5K, 1M, 1G, etc [duplicate]

我们两清 提交于 2019-12-18 00:49:21
问题 This question already has answers here : Format a number as 2.5K if a thousand or more, otherwise 900 (23 answers) Closed 6 years ago . I want to display numbers using a Metric Prefix with 3 significant digits like so: 1 shows as 1 999 shows as 999 1000 shows as 1K 999000 shows as 999K 1000000 shows as 1M 1500000 shows as 1.5M 1000000000 shows as 1G etc... I could write my own javascript function to do this but I was wondering if there is a standard way of formatting numbers like this? 回答1:

Line width formatting standard [closed]

ぐ巨炮叔叔 提交于 2019-12-17 23:34:07
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . Do you follow a standard for wrapping long lines in source code? What line length do you find most comfortable to read? Sometimes I

jquery nested ajax calls formatting

早过忘川 提交于 2019-12-17 22:40:05
问题 I have a requirement to make 6 ajax calls in succession based on data from the previous call. I am nesting each call in the success of the previous call. my question is what are some good ways to format the code so that it doesnt end up a million rows across my editor? $.ajax({ type: "POST", url: "someScript/someScript.php", data: form + "&func=build", success: function (result) { if (result == "ok") { $.ajax({ type: "POST", url: "someScript/someScript.php", data: form + "&func=someOtherFunc"