[1.0] Problem with Bool-Typecasting in XmlReader

  1. #1

    [1.0] Problem with Bool-Typecasting in XmlReader

    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

  2. #2

    RE: [1.0] Problem with Bool-Typecasting in XmlReader

    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
    https://examples1.ext.net/#/GridPane...eld_Converter/
  3. #3

    RE: [1.0] Problem with Bool-Typecasting in XmlReader

    Hi Vladsch,

    vladimir (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:

    <code class="wrappedText focusRow" role="listitem"><ArrayOfBookingOverviewEntry xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http:/</code><code class="wrappedText focusRow" role="listitem">/www.w3.org/2001/XMLSchema" xmlns="http://services.etask.de/">
    </code><code class="wrappedText focusRow" role="listitem">  <BookingOverviewEntry>
    </code><code class="wrappedText focusRow" role="listitem">    <Id>1526</Id>
    </code><code class="wrappedText focusRow" role="listitem">    <TicketNumber>018.000.005.444</TicketNumber>
    </code><code class="wrappedText focusRow" role="listitem">    <Date>2010-03-09T00:00:00</Date>
    </code><code class="wrappedText focusRow" role="listitem">    <StartTime>00:00</StartTime>
    </code><code class="wrappedText focusRow" role="listitem">    <EndTime>00:00</EndTime>
    </code><code class="wrappedText focusRow" role="listitem">    <RoomAnnotation>Büroraum check</RoomAnnotation>
    </code><code class="wrappedText focusRow" role="listitem">    <Topic>2. Test</Topic>
    </code><code class="wrappedText focusRow" role="listitem">    <Participants>1</Participants>
    </code><code class="wrappedText focusRow" role="listitem">    <Annotation />
    </code><code class="wrappedText focusRow" role="listitem">    <DateId>1526</DateId>
    </code><code class="wrappedText focusRow" role="listitem">    <Status>gebucht</Status>
    </code><code class="wrappedText focusRow" role="listitem">    <BeverageUrl>0</BeverageUrl>
    </code><code class="wrappedText focusRow" role="listitem">    <CateringUrl>0</CateringUrl>
    </code><code class="wrappedText focusRow" role="listitem">    <ChangedToday>true</ChangedToday>
    </code><code class="wrappedText focusRow" role="listitem">    <CateringStatus>0</CateringStatus>
    </code><code class="wrappedText focusRow" role="listitem">    <BeverageStatus>0</BeverageStatus>
    </code><code class="wrappedText focusRow" role="listitem">  </BookingOverviewEntry>
    </code><code class="wrappedText focusRow" role="listitem">  <BookingOverviewEntry>
    </code><code class="wrappedText focusRow" role="listitem">    <Id>1536</Id>
    </code><code class="wrappedText focusRow" role="listitem">    <TicketNumber>018.000.005.475</TicketNumber>
    </code><code class="wrappedText focusRow" role="listitem">    <Date>2010-03-09T00:00:00</Date>
    </code><code class="wrappedText focusRow" role="listitem">    <StartTime>14:00</StartTime>
    </code><code class="wrappedText focusRow" role="listitem">    <EndTime>14:30</EndTime>
    </code><code class="wrappedText focusRow" role="listitem">    <RoomAnnotation>Entwicklerbüro</RoomAnnotation>
    </code><code class="wrappedText focusRow" role="listitem">    <Topic />
    </code><code class="wrappedText focusRow" role="listitem">    <Participants>1</Participants>
    </code><code class="wrappedText focusRow" role="listitem">    <Annotation />
    </code><code class="wrappedText focusRow" role="listitem">    <DateId>1536</DateId>
    </code><code class="wrappedText focusRow" role="listitem">    <Status>gebucht</Status>
    </code><code class="wrappedText focusRow" role="listitem">    <BeverageUrl>1536</BeverageUrl>
    </code><code class="wrappedText focusRow" role="listitem">    <CateringUrl>0</CateringUrl>
    </code><code class="wrappedText focusRow" role="listitem">    <ChangedToday>false</ChangedToday>
    </code><code class="wrappedText focusRow" role="listitem">    <CateringStatus>0</CateringStatus>
    </code><code class="wrappedText focusRow" role="listitem">    <BeverageStatus>1</BeverageStatus>
    </code><code class="wrappedText focusRow" role="listitem">  </BookingOverviewEntry>
    You see... the first ChangedToday is true, the other is false.
    But with
    </code>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
  4. #4

    RE: [1.0] Problem with Bool-Typecasting in XmlReader

    Ok, thanks for the clarification. I will check boolean parsing in the XmlReader today
  5. #5

    RE: [1.0] Problem with Bool-Typecasting in XmlReader

    Hi,

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

    RE: [1.0] Problem with Bool-Typecasting in XmlReader

    Ahh ok. Thank you very much.


Similar Threads

  1. Store - XmlReader - Gridpanel
    By ontiv in forum 1.x Help
    Replies: 4
    Last Post: Jun 05, 2012, 10:47 AM
  2. [CLOSED] Why ThreeStateBool instead Nullable<bool>?
    By pil0t in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Aug 31, 2010, 2:38 PM
  3. XmlReader With Paging?
    By Tbaseflug in forum 1.x Help
    Replies: 12
    Last Post: Aug 15, 2009, 9:59 PM
  4. Replies: 2
    Last Post: Apr 02, 2009, 6:43 PM
  5. [CLOSED] XmlReader
    By Ben in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Jan 06, 2009, 12:28 PM

Posting Permissions