Notifications
Clear all

[Solved] Report Filter - Require a Field

2 Posts
3 Users
0 Reactions
866 Views
0
Topic starter

Is there a built-in way for a report to require that one of the filters is entered without specifying any of them individually as required?

What I'm asking is, is there any default behavior that we have to require that the user input something into at least one of the filters?

If not, then I'm just going to extend One.Report or use a Report JS Listener class.

2 Answers
0

It is very easy to implement using report plugin js. It will something like below.

AIDN.LogicalInventoryPivotPlugin = Ext.extend(Object, {
    init: function(report){
        report.on({
            formconfig: this.onFormConfig
            ,scope: this
        });

    }
    ,onFormConfig: function(report,formJson){
      var validatePlugin = new One.form.FormValidatorPlugin({

        validator:  function(basicForm){
            var allValues = basicForm.getValues();
            /*At least one of the filters should be provided*/
            if(!Ext.isEmpty(allValues['Undefined$Item']) || !Ext.isEmpty(allValues['Undefined$Program'])
                || !Ext.isEmpty(allValues['Undefined$ProductGroup']) || !Ext.isEmpty(allValues['Undefined$Site'])
                || !Ext.isEmpty(allValues['Undefined$SiteGroup']) || !Ext.isEmpty(allValues['Undefined$ItemClass'])) {
              return;
            }
            return Labels.get('meta.error.AIDN.LogicalInventoryPivot.specifyOneFilter');

        }

        });

        formJson.plugins = [validatePlugin];

    }
});
0

No such core feature exists - JS Listener is probably the way to go.