Flex DataGrid 从 lastResult.node 读取字段作为数字
为什么 Flex 3 DataGrid 从 XML lastResult.node 读取字符串作为数字?
一个字段在mysql中保存为var_char,php将其读取为字符串并传递即可。 如果字符数超过 16 个,则会四舍五入......
例如: 这在数据库单元格中: 12345678901234567 在 DataGrid 中读取数字为 12345678901234568,
这是在数据库单元格中: 5555544444222223333377777 php 读取它并将其放入 XML 中 flex 将 XML 读取到 arrayCollection 中,DataGrid 将其读取为: 5.55554444422222e+24
所以它读作数字,为什么?以及如何让它读取为字符串?
我尝试使用 labelFunction,但没有帮助。
Why does Flex 3 DataGrid read a string from XML lastResult.node as number?
A field is saved as var_char in mysql, php reads it as string and pass it OK.
If there are more then 16 charaters it gets rounded....
For example:
this in database cell:
12345678901234567
gets read in DataGrid as nubmer as 12345678901234568
this is in database cell:
5555544444222223333377777
php reads it same and puts it in XML
flex reads XML into arrayCollection and DataGrid reads it as:
5.55554444422222e+24
So it reads it as number, why? And how to make it read as String?
I tried with labelFunction, no help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
因为 XML 实际上只是一长串字符,所以 Flex 将它们视为松散类型变量,这实际上意味着 Flex 会查看数据并尽力确定数据的数据类型。逻辑的简化版本可能是:里面有字母字符吗?那么它是一个字符串。所有数字?好吧,那就是一个数字。
我认为解决这个问题的方法是将变量设置为特定类型,然后将该变量设置为等于 XML。因此,在您的情况下,
我没有实际测试
过这一点,所以如果这不起作用,请尝试一些变体,例如 myValue = myXML.crazyNumberString.toString(); 和 myValue = myXML。 madNumberString.toXMLString;
Because XML is really just a long string of characters, Flex treats them as loosely typed variables, which just really means that flex looks at the data and does it's best to determine what datatype the data is. A simplified version of the logic might go: Any alpha chars in there? then it's a string. All numbers? okay, then it's a number.
I think a way to get around it is to set a variable to a particular type then setting that variable equal to the XML. So in your case instead of
try
I haven't actually tested this so if that doesn't work try some variations like
myValue = myXML.crazyNumberString.toString();
and myValue =myXML.crazyNumberString.toXMLString;
我发现问题在于使用 arrayCollection 作为数据提供者,现在使用 XMLListCollection 可以正常工作!
I found that problem was in using arrayCollection as dataprovider, now with XMLListCollection it works OK!