Announcement

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

    Listgrid: column with displayfield can only be sorted once

    Hi,
    I have a listgrid with a column/field with a displayfield, I can only sort once on this field, a second click on the column header to sort the opposite direction is ignored.

    This can be reproduced with an example where the listgrid is backed by a datasource (the examples with just an array as the data work fine), for example the feature explorer: dataSourceFields

    Use this code:
    Code:
    isc.ListGrid.create({
        ID: "countryList",
        width:500, height:224, alternateRecordStyles:true, 
        dataSource: countryDS,
       fields:[
            {name:"countryName", title:"Country", displayField: 'government'}
        ],
        autoFetchData: true
    })
    Then click on the column header, it is sorted. Click again, the sort action is ignored.

    This happens in 8.3 using the latest nightly. For the following case:
    - the listgrid has a datasource
    - the field does not have a datasource
    - the field has a displayField set and the displayField does not occur as a 'normal' field in the grid
    - the displayField is not present in the datasource fields set either, but the displayField is present in the data

    This is the case for the dataSourceFields example with the code provided above.

    It works fine in 8.1.

    The issue seems to be in the ListGrid.setSort method, at the second click it gets a sortspecifier with an object which has the displayField as the property. If the displayField is not a field in the grid it won't find it using the ListGrid.getUnderlyingField method.
    In 8.3 a new newSpecifiers variable was introduced which is only filled if the field was found, in 8.1 the code continued with the old sortSpecifier.

    gr. Martin
    Last edited by martintaal; 26 Apr 2012, 07:48.

    #2
    What exact version are you using? A similar known issue was fixed fairly recently and we're seeing your test work fine against latest code.

    getUnderlyingField() should always return a field-definition if it exists, either as a visible or hidden field on a DBC, or a field which exists only in the DataSource. If you can see an example of that not happening against the latest nightly, please let us know.

    Comment


      #3
      I use the 8.3d version from the 26th of April.

      My point is a bit that in this case getUnderlyingField is called using the displayField name. in our case the displayField is not defined as a separate field for the datasource or grid, so it won't find any field.

      What I propose is that if the getUnderlyingField does not find anything that it should try to find the correct field using the displayField property of the ListGridField.

      So we have a for example this listgrid field:
      {
      name: 'organization'
      displayField: 'organization_identifier'
      }

      When I sort on this one the getUnderlyingField is called with 'organization_identifier', we don't have a separate field definition for that one so the getUnderlyingField doesn't find a field. So I propose that if no field is found that an extra search is done on the displayField property of the list grid fields, then the organization field will be found.

      gr. Martin

      Comment


        #4
        It sounds like you're expecting to be able to sort on a field which is not defined anywhere, either at the ListGrid or DataSource level, but who's values happen to appear in the data, right?

        If so, that isn't expected to work - we don't support sorting on arbitrary data that has no field-definition.

        If this isn't what you're trying to do, then it's not clear why you would want to set up a field with a displayField that doesn't exist.

        Comment


          #5
          I try to minimize the datasource definition javascript, it is generated on the server and then send to the client. These fields are present in the data but only for displayfields of reference fields (foreign keys).
          So they are not present in the DBC.

          I could try to add them automatically to the datasource on the client, so after the datasource creation I would like to add new fields to the datasource. Is this possible/doable somehow?

          gr. Martin

          Comment


            #6
            Btw, as an extra remark, sorting using the context header menu works fine (there I can continuously switch between up/down sorting).

            So there the displayField is handled in a way that works for me it seems.

            gr. Martin

            Comment


              #7
              Does the field you want to sort on happen to be the first visible one in the grid?

              Comment


                #8
                It is, but when I try the example with another first column I can still reproduce it on the second column.

                Code:
                isc.ListGrid.create({
                    ID: "countryList",
                    width:500, height:224, alternateRecordStyles:true, 
                    dataSource: countryDS,
                   fields:[
                {name: 'countryCode'}, 
                        {name:"countryName", title:"Country", displayField: 'government'}
                    ],
                    autoFetchData: true
                })
                This code has to be tested in SmartClient_Explorer.html#dataSourceFields

                Also realize that if you use the small grid button that shows the dropdown menu, using "Sort Ascending" and "Sort Descending" it works ok, but clicking directly in the header, it doesn't
                Last edited by martintaal; 27 Apr 2012, 05:11.

                Comment


                  #9
                  Is that second example intended to show an error when using the default countryDS DataSource? Because that one too appears to work as expected for us - I can repeatedly sort on either of the fields in the grid with the header-buttons or the menu.

                  Can you confirm browser details?

                  Comment


                    #10
                    To summarize:
                    It can be reproduced with this example:
                    SmartClient_Explorer.html#dataSourceFields
                    changing tab "fieldsDS.js" code with the provided one.

                    If you click in the header "Country", the second time you click in the header text, it doesn't sort anymore.

                    Using the dropdown menu and clicking "Sort Ascending"/"Sort Descending" works always.

                    It happens in all browsers.

                    P.S.: We are testing againts "SmartClient_SNAPSHOT_v83d_2012-04-27_LGPL" but it happens at least since one week ago
                    Last edited by martintaal; 27 Apr 2012, 05:22.

                    Comment


                      #11
                      Ok, thanks for the report - we see the problem now and a fix is in testing - should hit nightlies in a day or so

                      Comment

                      Working...
                      X