Announcement

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

    Summary column becomes filterable after grid state restore

    Hi,
    This is slightly modified showcase example:
    Code:
    isc.DataSource.create({
        ID: "viewState",
        dataFormat: "sql",
        clientOnly: true,
        fields: [
            {name: "pk", primaryKey: true, hidden: true},
            {name: "name", title: "Name"},
            {name: "viewState", title: "View State"}
        ]
    });
    
    var ds = isc.DataSource.get("countryDS");
    var tableDS = isc.DataSource.get("viewState");
    var lastNum = 1;
    
    isc.ListGrid.create({
        ID: "viewStateTable",
        height: 200, width: "100%",
        wrapCells: true,
        fixedRecordHeights: false,
        canEdit: true,
        autoDraw: false,
        emptyMessage: "No Saved Preferences",
        canRemoveRecords: true,
        autoFetchData: true,
        dataSource: tableDS,
        fields: [
                {name: "name", title: "Preference", width: 100},
                {name: "viewState", title: "View State String", editorType: "textArea"}
        ]
    });
    isc.ListGrid.create({
        ID: "countryGrid",
        width: "100%", height: 200,
        leaveScrollBarGap: true,
        canGroupBy: true,
        autoDraw: false,
        canFreezeFields: true,
        canAddFormulaFields: true,
        canAddSummaryFields: true,
        dataSource: ds,
        autoFetchData: true,
        showFilterEditor: true,
    draw : function() {
            this.Super("draw", arguments);
            viewStateTable.addData({pk: 0, name: "Default", viewState: this.getViewState()});
            preferenceSelectItem.setValue("Default");
        }   
    });
    
    isc.DynamicForm.create({
        top: 45,
        width: 200,
        ID: "preferenceForm",
        numCols: 2,
        autoDraw: false,
        fields: [
                {name: "name", title: "Preference", type: "select",  ID: "preferenceSelectItem", displayField: "name",
                addUnknownValues:true, optionDataSource: viewState,
                 changed: function(form, item, value) {
                  var criteria = {name: value};
                   viewState.fetchData(criteria, function(dsResponse, data) {
                            if (data.length != 0) {
                                var selectedViewState = data[0].viewState;
                                countryGrid.setViewState(selectedViewState);
                            }
                        });
                    }
                }
        ]
    });
    isc.ToolStripButton.create({
        ID: "formulaBuilder",   
        autoDraw: false,
        icon: "icons/16/sc_insertformula.png", 
        title: "Formula Builder",
        autoFit: true,
        click : function () {
            countryGrid.addFormulaField();
        }  
    });
    
    isc.ToolStripButton.create({
        ID: "summaryBuilder",   
        autoDraw: false,
        icon: "icons/16/application_side_tree.png", 
        title: "Summary Builder",
        autoFit: true,
        click : function () {
            countryGrid.addSummaryField();
        }
    });
    
    isc.ToolStripButton.create({
        ID: "savePreference",   
        icon: "icons/16/database_gear.png", 
        title: "Save Preference",
        autoDraw: false,
        autoFit: true,
        click : function () {
            isc.askForValue("Save Preference as",
                        function(value) {
                        if (value) {
                            viewStateTable.addData({pk: lastNum, name: value, viewState: countryGrid.getViewState()});
                            lastNum = lastNum + 1;
                            preferenceSelectItem.setValue(value);
                         }
                        },
                        {width: 300, height: 100})
        }
    });
    
    
    
    isc.ToolStrip.create({
        ID: "preferenceStrip",
        width: "100%",
        addFill: true,
        align: "right",
        autoDraw: false,
        members: [formulaBuilder, summaryBuilder, "separator", savePreference,
                  "separator",  preferenceForm]
    });
    
    isc.ToolStripButton.create({
        ID: "restoreState",   
        autoDraw: false,
        title: "Restore State",
        icon: "icons/16/database_gear.png", 
        autoFit: true,
        click : function () {
            countryGrid.setDataSource(ds);
            countryGrid.fetchData();
            preferenceForm.setValue("name", "Default");
        }
    });
    
    isc.ToolStrip.create({
        ID: "restoreStrip",
        width: "100%",
        addFill: true,
        autoDraw: false,
        align: "right",
        members: [restoreState]
    });
    
    isc.VLayout.create({
        height: "100%",
        width: 700,
        members: [preferenceStrip, countryGrid, viewStateTable, restoreStrip]
        });
    Changes are:
    - grid has filter editor enabled
    - Restore state button performs "truly" restore by re-attaching to the ds

    You will get this:
    Click image for larger version

Name:	formula field canFilter after state restore0.png
Views:	141
Size:	77.1 KB
ID:	240732

    Then use summary builder and create any summary column:
    Click image for larger version

Name:	formula field canFilter after state restore1.png
Views:	47
Size:	79.8 KB
ID:	240733
    As you can see the summary column has filter editor disabled.

    Now save this grid state using "Save preferences" button:
    Click image for larger version

Name:	formula field canFilter after state restore2.png
Views:	62
Size:	112.8 KB
ID:	240734
    Then restore grid's state using right lower corner "Restore State" button and finally choose again previously saved "test" state using Preferences SelectItem:
    Click image for larger version

Name:	formula field canFilter after state restore3.png
Views:	57
Size:	101.2 KB
ID:	240735
    You can see now that summary column filter editor is enabled (but it shouldn't as filtering by it is not possible server side).

    SmartClient Version 11.0p 2016-10-12

    Thanks,
    MichalG

    #2
    We'll take a look and get back to you when we have more information.

    Comment


      #3
      This has been fixed for builds dated October 20 and later.

      Comment


        #4
        Verified as fixed in SmartClient Version: v11.0p_2016-10-23/LGPL Development Only (built 2016-10-23).
        Thank you.
        MichalG

        Comment

        Working...
        X