Announcement

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

    order of field in ListGrid with useAllDataSourceFields == true

    Hi,

    Tested in current showcase.

    I am not sure if this is intended behaviour, but setting useAllDataSourceFields to true make ListGrid ignore order of fields in .field or .defaultFields attribute and order fields like in DS.

    This is modified showcase "Merged fields":

    Code:
    isc.ListGrid.create({
        ID: "countryList",
        width:500, height:224, alternateRecordStyles:true,
    [B]useAllDataSourceFields: true,[/B]
        fields:[
        // move countryCode before country name and replace with flag image/title
            {name:"countryCode", title:"Flag", width:40, type:"image", imageURLPrefix:"flags/16/", imageURLSuffix:".png"},
            {name:"countryName"},
        // change title and alignment of independence date
            {name:"independence", title:"Nationhood", align:"center", width:100},
        // change format of population from the one on the DataSource
            {name:"population", format:"0.0"},
        // format GDP as $M instead of $B
            {name:"gdp", title:"GDP ($M)", formatCellValue:"isc.NumberUtil.format(value*1000, ',0')"}
        ],
        dataSource: countryDS,
        autoFetchData: true
    })
    current result:
    fields in ListGrid in order countryName, countryCode, indepenence...

    expected result:
    fields in ListGrid in order countryCode, countryName, independence...

    Best regards,
    Janusz

    #2
    We would suggest reading the documentation for the property you are using...

    Comment


      #3
      Documentation for useAllDataSourceFields does not mention anything regarding order of fields existing in both component.fields and DS.fields. I would expect that the order will also be overridden with unmentioned fields from DS appearing after.

      Is then the only default way to provide default ordering of fields in LG different from DS is LG.setFieldState()?

      Comment


        #4
        From docs for useAllDataSourceFields:

        If true, the set of fields given by the "default binding" (see DataBoundComponent.fields) is used
        From linked docs for DBC.fields:

        If a DataBoundComponent is given a DataSource, but no component.fields, the "default binding" is used: fields are shown in DataSource order,
        Back to useAllDataSourceFields:

        If component.fields contains fields that are not found in the DataSource, they will be shown after the most recently referred to DataSource field. If the new fields appear first, they will be shown first.
        So, all working as described, and as designed. There's even a sample!

        And no, the way to provide an ordering of fields that is different from the DS is just setFields(). As is covered here and in the QuickStart Guide, when you call setFields(), you don't have to recapitulate any settings from the DS that remain unchanged. So you can call setFields() to reorder the fields, and all you have to do is name the field by it's name property, very minimal code.

        Comment

        Working...
        X