value is not an instance of String. It's an Object for the render which
contains the grid data.

What the sample is trying to do is to convert the value into formatted
string: "$880" for display purpose. But for some reason, the formatting
failed:

NumberFormat nf = NumberFormat.getCurrencyFormat();

return nf.format(((Number) value).doubleValue());

It's very strange that I have this problem. It seems that no one else has
encountered this problem.

Thanks a lot for your help.

M.Y.

On Fri, Oct 9, 2009 at 11:47 AM, Patrizio De Michele <[email protected]>wrote:

> emh...maybe i wasn't clear...if (value instanceof String)  {
> } else {
>    value.toString();
> }
>
>
> 2009/10/9 mingqiang yu <[email protected]>
>
> The original data is populated just fine the grid. It's just that when I
>> update the value in the grid, things go wrong. I tried to put this line to
>> check if it's an instance of String:
>>
>>  Renderer renderer = new Renderer() {
>>                 public String render(Object value, CellMetadata
>> cellMetadata, Record record, int rowIndex, int colNum, Store store) {
>>                     NumberFormat nf = NumberFormat.getCurrencyFormat();
>>                     if ( nf.format(((Number) value).doubleValue())
>> instanceof String ) {
>>                         value = nf.format(((Number) value).doubleValue());
>>                     }
>>                    return value.toString(); // works fine
>>                 }
>> };
>>
>> But the problem is that the code was stuck at the checking point:
>> if ( nf.format(((Number) value).doubleValue()) instanceof String ) {
>>
>> It seems that the Number casting to the value variable makes the program
>> go crazy. But I really have no clue how I can fix it.
>>
>> Many thanks for your help!
>>
>> M.Y.
>>
>>
>>
>> On Fri, Oct 9, 2009 at 11:22 AM, Patrizio De Michele <[email protected]
>> > wrote:
>>
>>> check if is an instance of number or instead is a string.....
>>>
>>>
>>> 2009/10/9 my600080 <[email protected]>
>>>
>>>
>>>> I tried to debug some more and here is what I found. The problem is in
>>>> the line chart renderer. Here is the original code from gwtext 2.0.6
>>>> sample LineChartSample.java code:
>>>>
>>>>            Renderer renderer = new Renderer() {
>>>>                public String render(Object value, CellMetadata
>>>> cellMetadata, Record record, int rowIndex, int colNum, Store store) {
>>>>                    NumberFormat nf = NumberFormat.getCurrencyFormat
>>>> ();
>>>>                    return nf.format(((Number) value).doubleValue());
>>>>               }
>>>>            };
>>>>
>>>> For this piece of code, if I update the value in the line chart data
>>>> grid, the value will not get updated and so the chart is not
>>>> refreshed.
>>>>
>>>> If I change the above as following:
>>>>
>>>>            Renderer renderer = new Renderer() {
>>>>                public String render(Object value, CellMetadata
>>>> cellMetadata, Record record, int rowIndex, int colNum, Store store) {
>>>>                    return value.toString();
>>>>               }
>>>>            };
>>>>
>>>>
>>>> Then the line chart data grid update works just fine (of course, it's
>>>> not formatted any more) and so the chart is refreshed correctly with
>>>> the new data.
>>>>
>>>> Do you know what the problem might be? Is it possible that I cannot
>>>> cast the value object inside the renderer?
>>>>
>>>> Your help is highly appreciated!
>>>>
>>>> M.Y.
>>>>
>>>> On Oct 7, 4:27 pm, my600080 <[email protected]> wrote:
>>>> > I'm using Eclipse Galileo, GWT 1.7 and GWT-EXT 2.0.6. I copied the
>>>> > Charts samples into my workspace. Everything works ok except that when
>>>> > I tried to update the values in the Grid for any of the charts, the
>>>> > change reverses back right away to the old value. Is this something
>>>> > that anyone else has experienced as well? Or is it just me? Thanks!
>>>> >
>>>> > M.Y.
>>>>
>>>>
>>>
>>>
>>>
>>
>>
>>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"GWT-Ext Developer Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/gwt-ext?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to