Editor: Universally disable editing based on condition

Editor: Universally disable editing based on condition

raydlevel5raydlevel5 Posts: 98Questions: 43Answers: 1

How might I prevent editing if a certain value (locked) is set to true?

I have 5 DataTable instances, and 5 associated Editor instances.

The 1st table/editor set has a field called "Locked". If this is set to true, I don't want ANY of the dependent entries in the corresponding 4 tables + 4 editors to be modified... just viewed only.

I'm thinking of creating a "global" variable in the application named "locked", and then maybe using readonly on all the fields, somehow.

Is there a way to universally disable editing on an Editor instance based on some condition?

Should I create my own function that accepts a DTE instance name, and maybe this function could get all the instance's field names, and disables them all, or something...

Something Like... dteInstanceName.field( '[ALL FIELDS]' ).disable();

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 6,890Questions: 0Answers: 1,177

    Hi @raydlevel5 ,

    You could have that test in the preOpen event. If that event handler returns false, then the event is cancelled, effectively making the table read-only.

    Cheers,

    Colin

  • raydlevel5raydlevel5 Posts: 98Questions: 43Answers: 1

    I should have mentioned that I still want to Editor form to open... for viewing only...

  • colincolin Posts: 6,890Questions: 0Answers: 1,177
    Answer ✓

    Ah, yep, then I think you're right, you'll need to add the readonly to the fields. I imagine in that preOpen, you would do your test - and either add the fields to the form with readonly or not, depending on the result.

    C

Sign In or Register to comment.