Announcement

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

    [Bug] Listgrid useAdvancedFieldPicker column order [includes example]

    Version v10.0p_2015-10-05/LGPL Development Only (2015-10-05)

    If a datasource is attached to a listgrid and useAllDataSourceFields is true and you select columns from the advancedfieldpicker, the requested order is not applied.
    check this behaviour in the example below:
    Add field one after field two, in the resulting list field1 will before field2. This is inconsistent.
    This does work, if useAllDataSourceFields is false.

    Example @http://www.smartclient.com/docs/10.0/a/system/reference/SmartClient_Explorer.html#fieldPicker:
    Code:
            function createDS(fieldCount) {
                var fields = [];
                for(var i = 1; i <= fieldCount; i++) {
                    fields.add({name: "field" + i, title: "Field " + i, showIf: "false"});
                }
                return isc.DataSource.create({
                    ID:'test',
                     fields:fields,
                     cacheData:createRecords(100,fields),
                     clientOnly:true
                })
            }
    
            function createRecords (recordCount, fields) {
                var records = [];
                for (var i = 0; i < recordCount; i++) {
                    var record = {};
                    for (var j = 0; j < fields.length; j++) {
                        record[fields[j].name] = "Row " + i + ", Value " + (j+1);
                    }
                    records.add(record);
                }
                return records;
            }
    
            function getOrderedFields(fields) {
                var initialFieldIndices = [ 2 ],
                    i, orderedFields = [];
    
                for (i = 0; i < initialFieldIndices.length; i++) {
                    var field = fields["field" + initialFieldIndices[i]];
                    orderedFields.add(field);
                    delete field.showIf;
                }
    
                var keys = isc.getKeys(fields)
                for (i = 0; i < keys.length; i++) {
                    var field = fields[keys[i]];
                    if (field.showIf != null) orderedFields.add(field);
                }
    
                return orderedFields;
            }
    
            
            var ds = createDS(4);
    
            isc.ListGrid.create({
                ID: "pickableFields",
                useAllDataSourceFields:true,
                autoDraw:true,
                width:500,
                height:400,
                dataSource:ds,
                autoFetchData:true,
                autoFitData: "both",
                autoFitMaxRecords: 20,
                autoFitMaxColumns: 8,
                autoFitFieldWidths: true,
                canEditTitles: true,
                fields:getOrderedFields(ds.fields),
                useAdvancedFieldPicker: true,
                fieldPickerFieldProperties: [ "frozen" ],
    
                getBaseStyle: function (record, rowNum, colNum) {
                    return colNum % 2 == 0 ? "myEvenGridCell" : "myOddGridCell";
                }
            });
    
            pickableFields.delayCall("editFields");

    #2
    The problem is that when useAllDataSourceFields is set to true, that implies that all the fields of the grid that are also in the DataSource are kept in DataSource order. To allow the FieldPicker to work in this situation, we've modified it to force useAllDataSourceFields to false when the user applies the specified ordering. The fix has been applied to SmartClient 10.0p and newer and will be in the nightly builds marked 2015-10-22.

    As a workaround, you could simply set the property to false in your own code before triggering the FieldPicker.

    Comment

    Working...
    X