[1.0] Problem with Bool-Typecasting in XmlReader
New Community Forums available at http://forums.ext.net
 

Coolite Forums

Welcome Guest ( Login | Register )
 
[1.0] Problem with Bool-Typecasting in...
Subscribe
Last Login: 6/24/2010 7:26:21 AM
Posts: 259,
Posted 3/9/2010 2:57:37 AM

Group: Coolite Premium Member & Early Adopter
 Hello,

we are near to finish our upgrade from 0.82 to 1.0.
During that update I just had a little problem with the following lines ..


  function markRow(record) {
        if (record.data.ChangedToday) {
            return 'changed-row';
        }
    }

<ext:Store runat="server" ID="BookingListStore" AutoLoad="true" GroupField="Date">
    <Reader>
        <ext:XmlReader Record="BookingOverviewEntry" IDPath="DateId">
            <Fields>
                <ext:RecordField Name="DateId" Type="Int" />
                <ext:RecordField Name="TicketNumber" Type="String" />
                <ext:RecordField Name="Date" Type="Date" />
                <ext:RecordField Name="StartTime" Type="String" />
                <ext:RecordField Name="EndTime" Type="String" />
                <ext:RecordField Name="Status" Type="String" />
                <ext:RecordField Name="RoomAnnotation" Type="String" />
                <ext:RecordField Name="Topic" Type="String" />
                <ext:RecordField Name="Participants" Type="Int" />
                <ext:RecordField Name="Annotation" Type="String" />
                <ext:RecordField Name="BeverageUrl" Type="String" />
                <ext:RecordField Name="CateringUrl" Type="String" />
                <ext:RecordField Name="ChangedToday" Type="Boolean"/>
                <ext:RecordField Name="CateringStatus" Type="int" />
                <ext:RecordField Name="BeverageStatus" Type="int" />
            </Fields>
        </ext:XmlReader>
    </Reader>
</ext:Store>


// grid...

  <View>
                        <ext:GroupingView ID="GroupingView1" runat="server" ForceFit="true" ShowGroupName="true"
                            EnableNoGroups="true" HideGroupedColumn="true">
                            <GetRowClass Fn="markRow" />
                        </ext:GroupingView>
                    </View>



It´s a bit complicated to show a whole simple example because I am defining the DataSource as WebService in codebehind and so on.

But all in all marking the rows if ChangedToday= true worked fine in Coolite 0.82.
Now it does not work anymore in that way. Because my solution is too diffcult to show here,  I tried to make a simple example which uses a JSONReader. But this example worked fine too.

So I think the problem is somewhere in the XmlReader and the typcasting to a bool.

I can only guess but If I guess I would say the ChangedToday column is still a string (not a bool) also when I cast it in the RecordField, because when I change my code to:



 function markRow(record) {
        if (record.data.ChangedToday=='true') {  // instead of    if (record.data.ChangedToday) { which worked in 0.82
            return 'changed-row';
        }
    }




everything runs fine.



Regards,

Martin

Last Login: 7/5/2010 10:10:13 AM
Posts: 7,853,
Posted 3/9/2010 6:48:50 AM

Group: Core Development Team
Hi,

Can you post current value of the 'ChangedToday'?

Even if that field contains string instead bool that 'if' statement executes true branch because any none empty string is considered as true by javascript engine

So, if
ChangedToday="true";

then the following code is equivalent
if (record.data.ChangedToday) {

if (record.data.ChangedToday=='true')

Also you can use Convert for that field

--
Vladimir Shcheglov
Coolite Inc.
Development Team
Forum Guidelines | Coolite Examples | Coolite API Docs | ExtJS API Docs | Twitter
Last Login: 6/24/2010 7:26:21 AM
Posts: 259,
Posted 3/9/2010 8:12:52 AM

Group: Coolite Premium Member & Early Adopter
Hi Vladsch,

vladsch (3/9/2010)
Hi,

Can you post current value of the 'ChangedToday'?

Even if that field contains string instead bool that 'if' statement executes true branch because any none empty string is considered as true by javascript engine

So, if
ChangedToday="true";

then the following code is equivalent
if (record.data.ChangedToday) {

if (record.data.ChangedToday=='true')


Yes I know that a string is always true. That´s why I am thinking it´s always a string and the Type-Parsing does not work for Xml.

Here is an Xml example from my webservice:


<ArrayOfBookingOverviewEntry xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://services.etask.de/">
<BookingOverviewEntry>
<Id>1526</Id>
<TicketNumber>018.000.005.444</TicketNumber>
<Date>2010-03-09T00:00:00</Date>
<StartTime>00:00</StartTime>
<EndTime>00:00</EndTime>
<RoomAnnotation>Büroraum check</RoomAnnotation>
<Topic>2. Test</Topic>
<Participants>1</Participants>
<Annotation />
<DateId>1526</DateId>
<Status>gebucht</Status>
<BeverageUrl>0</BeverageUrl>
<CateringUrl>0</CateringUrl>
<ChangedToday>true</ChangedToday>
<CateringStatus>0</CateringStatus>
<BeverageStatus>0</BeverageStatus>
</BookingOverviewEntry>
<BookingOverviewEntry>
<Id>1536</Id>
<TicketNumber>018.000.005.475</TicketNumber>
<Date>2010-03-09T00:00:00</Date>
<StartTime>14:00</StartTime>
<EndTime>14:30</EndTime>
<RoomAnnotation>Entwicklerbüro</RoomAnnotation>
<Topic />
<Participants>1</Participants>
<Annotation />
<DateId>1536</DateId>
<Status>gebucht</Status>
<BeverageUrl>1536</BeverageUrl>
<CateringUrl>0</CateringUrl>
<ChangedToday>false</ChangedToday>
<CateringStatus>0</CateringStatus>
<BeverageStatus>1</BeverageStatus>
</BookingOverviewEntry>


You see... the first ChangedToday is true, the other is false.
But with

if (record.data.ChangedToday) {


it´s always marked as changed, also when ChangedToday = false in my Xml.


For me it´s not a problem because I handle it as string now.
But maybe you should have a look into the  type-parsing of your code.

As I said... with a JsonReader it works fine!



Regards,

Martin
Last Login: 7/5/2010 10:10:13 AM
Posts: 7,853,
Posted 3/9/2010 8:16:40 AM

Group: Core Development Team
Ok, thanks for the clarification. I will check boolean parsing in the XmlReader today 
--
Vladimir Shcheglov
Coolite Inc.
Development Team
Forum Guidelines | Coolite Examples | Coolite API Docs | ExtJS API Docs | Twitter
Last Login: 7/5/2010 10:10:13 AM
Posts: 7,853,
Posted 3/9/2010 8:54:32 AM

Group: Core Development Team
Hi,

Confirm, it is a bug (ExtJS). I have opened bug request on the ExtJS forum

--
Vladimir Shcheglov
Coolite Inc.
Development Team
Forum Guidelines | Coolite Examples | Coolite API Docs | ExtJS API Docs | Twitter
Last Login: 6/24/2010 7:26:21 AM
Posts: 259,
Posted 3/9/2010 8:55:48 AM

Group: Coolite Premium Member & Early Adopter
 Ahh ok. Thank you very much.


« Prev Topic | Next Topic »
Reading This Topic
Active Users: 0 ( 0 guests, 0 members, 0 anonymous members )
No members currently viewing this topic.
All times are GMT -5:00, Time now is 8:45pm