Editor: Using field().disable with an AJAX implementation

Editor: Using field().disable with an AJAX implementation

nick_psnick_ps Posts: 12Questions: 3Answers: 0

Description of problem:
Is it possible to disable an Editor field by passing the 'disable' attribute in JSON.

I have a client/server implementation of Datatables using Rails, and the client/server interaction is working robustly.

I have a requirement to disable Editor fields based on data generated on the server, and passed to the Datatables Editor via JSON.

Is the a way of passing the 'disable' attribute to an Editor field via JSON?

Answers

  • OSFOSF Posts: 18Questions: 0Answers: 0
    edited December 2022

    Check your response data and use in preOpen event handler:

    editor.on('preOpen', function (e) {
        let mode = editor.mode(); // Gets editor mode, (create, edit, remove)
        let modifier = editor.modifier();  // Gets the selected row of the table
        let data = table.row(modifier).data();
    
        if(  data.XXX == "xxx" ) {
            editor.field('YourField').disable();
        };
    });
    
Sign In or Register to comment.