Aller au contenu principal

Deny all fields except for a few

Commentaires

2 commentaires

  • Luke Bray

    Hi Marius, 

    This works for us to allow only a few specific fields and denying all others:
     

    const allowedSet = new Set(['type', 'survstatus']);
    // Deny all fields
    layer.fields.forEach((f) => {
        const fname = f && f.name;
        try {
            denyField(fname);
        } catch (e) {
            // Field might not exist on this layer?
        }
    });
    
    // Explicitly allow whitelisted fields
    allowedSet.forEach((fieldName) => {
        try {
            allowField(fieldName);
        } catch (e) {
            // Field might not exist on this layer?
        }
    });

     

    By the way, if you use denyfield do you find you can no longer sort any other fields ?

     

    (https://support.vertigis.com/hc/en-us/community/posts/27977032487186-Access-Control-Denied-Field-breaks-sorting)

    1
  • Marius Kreß

    Thank you for your replay. Your code works, but I still get the Varint errors.

    And yes, I also get the sorting bug.

    0

Vous devez vous connecter pour laisser un commentaire.