Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Topic] Customizing fields #386

Open
brianlagunas opened this issue Jan 10, 2024 · 0 comments
Open

[Topic] Customizing fields #386

brianlagunas opened this issue Jan 10, 2024 · 0 comments

Comments

@brianlagunas
Copy link
Member

Description

We need to document the onFieldsInitializing event which allows customers to customize the names, remove, and change positions of the fields.

revealView.onFieldsInitializing = function (args) {
            var editedFields = args.fields;
            // a example of how you can delete fields
            // list of field names to be deleted  
            var exclude = ["Date", "Budget", "CTR", "Avg.CPC", "Avg. CPC", "Traffic"];
 
            // deleted the fields 
            editedFields = editedFields.filter(f => !exclude.some(e => e == f.name));
 
            //change name to show to Spend field to Spent
            var fieldToChange = editedFields.find(f => f.name == "Spend");
            if (fieldToChange) { fieldToChange.label = "Spent"; }
 
            //change order
            args.useCustomSort = true; //when set to true the fields are displayed in the same order   as in args.fields
            // if you want to re order only the first two positions
            var newOrder = ["Organic %", "Spend"]; // change the order for the first two position, 

 
//for this example spend will be in the first position and Organic in the second position, 
            //the rest of the fields will be kept in the order they had in args fields 
            newOrder.forEach(function (field) {
                var moveFiled = editedFields.find(function (f) {
                    return f.name === field;
                });
                if (editedFields.indexOf(moveFiled) !== -1) {
                    editedFields.splice(editedFields.indexOf(moveFiled), 1);
                    editedFields.unshift(moveFiled);
                }
            });
            args.fields = editedFields
        }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant