Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Sorting a list grid containing a null value

    SmartGWT version: SmartClient Version: v10.1p_2016-08-05/PowerEdition Deployment (built 2016-08-05)
    Browsers: Firefox 50.0.2, IE 11, Chrome 54.0.2840.99

    Issue:
    I have a list grid containing a column that is a text value. The text value may be null.
    When sorting by that column, I expect that sorting should either have null values go to the top or to the bottom.

    The actual behaviour is that null values are sorted between alpha strings.

    Sample:

    UI Code:

    Code:
           CanvasItem canvasItem = new CanvasItem();
            ListGrid emailListGrid = new ListGrid();
            emailListGrid.setDataSource( DataSource.get( "email_address" ) );
            emailListGrid.setAutoFetchData( true );
            canvasItem.setCanvas( emailListGrid );
    The canvas item is set on a DynamicForm.

    DataSource XML:
    Code:
    <DataSource
        tableName="email_address"
        ID="email_address"
        dataSourceVersion="1"
        serverType="sql"
    >
        <fields>
            <field primaryKey="true" name="email_id" type="sequence" sequenceName="s_email_address" hidden="true"></field>
            <field name="email_address_name" type="ntext" length="128" required="true"/>
            <field name="email_address" type="ntext" required="true" />
            <field name="email_comment" type="ntext" length="255" />
        </fields>
    
        <operationBindings>
            <operationBinding operationType="fetch">
            </operationBinding>
            <operationBinding operationType="add">
            </operationBinding>
            <operationBinding operationType="update">
            </operationBinding>
            <operationBinding operationType="remove">
            </operationBinding>
        </operationBindings>
    </DataSource>
    DataSource fetch response:
    Code:
    {
        affectedRows:0, 
        data:[
            {
                email_id:1, 
                email_address:"c@c", 
                email_address_name:"c", 
                rowID:1
            }, 
            {
                email_id:2, 
                email_address:"a@a", 
                email_address_name:"a", 
                email_comment:"t", 
                rowID:2
            }, 
            {
                email_id:3, 
                email_address:"b@b", 
                email_address_name:"b", 
                email_comment:"x", 
                rowID:3
            }
        ], 
        endRow:3, 
        invalidateCache:false, 
        isDSResponse:true, 
        operationType:"fetch", 
        queueStatus:0, 
        startRow:0, 
        status:0, 
        totalRows:3
    }
    As seen in the attached image, sorting by email comment sorts the null value between t and x.

    Click image for larger version

Name:	email_comment_sort.PNG
Views:	173
Size:	4.7 KB
ID:	241747

    #2
    We're not reproducing this.

    Are you really reproducing this consistently across the 3 browsers you list, or are you just listing browsers you regularly use (please only list browsers where you have reproduced a specific problem, if so).

    What locale are you testing in?

    As a sanity check, can you please go here:

    http://www.smartclient.com/?skin=Enterprise#sort

    Edit the data to remove various values for "countryName" then "Try It" and try sorting. You should see all missing values sort together at the top or bottom. Please confirm.

    Comment


      #3
      I was able to reproduce it with the sample you provided. I've narrowed it down to when the type is ntext. All you need to do is use the following for sort.js and countryData, then "Try It" and try sorting by Country:

      Sort.js:
      Code:
      isc.ListGrid.create({
          ID: "countryList",
          width:500, height:224, alternateRecordStyles:true,
          data: countryData,
          fields:[
              {name:"countryCode", title:"Flag", width:50, type:"image", imageURLPrefix:"flags/16/", imageURLSuffix:".png"},
              {name:"countryName", title:"Country", type:"ntext"},
              {name:"population", title:"Population", format:",0"},
              {name:"area", title:"Area (km&sup2;)", format:",0"}
          ],
          // initial sort on Population, high-to-low
          sortFieldNum: 2,
          sortDirection: "descending"
      })
      countryData:
      Code:
      countryData = [
      
      {
          continent:"North America",
          countryName:"t",
          countryCode:"US",
          area:9631420,
          population:298444215,
          gdp:12360.0,
          independence:new Date(1776,6,4),
          government:"federal republic",
          government_desc:2,
          capital:"Washington, DC",
          member_g8:true,
          article:"http://en.wikipedia.org/wiki/United_states"
      },
      {
          continent:"Asia",
          countryCode:"CH",
          area:9596960,
          population:1313973713,
          gdp:8859.0,
          government:"Communist state",
          government_desc:0,
          capital:"Beijing",  
          member_g8:false,
          article:"http://en.wikipedia.org/wiki/China"
      },
      {
          continent:"Asia",
          countryName:"x",
          countryCode:"JA",
          area:377835,
          population:127463611,
          gdp:4018.0,
          government:"constitutional monarchy with parliamentary government",
          government_desc:1,
          capital:"Tokyo",
          member_g8:true,
          article:"http://en.wikipedia.org/wiki/Japan"
      },
      {
          continent:"Asia",
          countryName:"India",
          countryCode:"IN",
          area:3287590,
          population:1095351995,
          gdp:3611.0,
          independence:new Date(1947,7,15),
          government:"federal republic",
          government_desc:2,
          capital:"New Delhi",
          member_g8:false,
          article:"http://en.wikipedia.org/wiki/India"
      },
      
      ]
      Click image for larger version

Name:	country_sort.PNG
Views:	237
Size:	12.2 KB
ID:	241776

      Comment


        #4
        This has been fixed back to SGWT 5.1/SC 10.1, for builds dated December 10 and later.
        Last edited by Isomorphic; 9 Dec 2016, 03:33.

        Comment


          #5
          Thank-you. I verified with the build from 2016-12-12.

          Comment

          Working...
          X