dynamic read only

dynamic read only

montoyammontoyam Posts: 568Questions: 136Answers: 5

There are times I want the user to be able to open the editor (because it has more fields displayed than the data table) but I don't want them to be able to update anything. Is there a way to remove the 'Update' button or changing the action of the update button to close without saving?

If (readOnly==1) {
//remove or change update button
}

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,144Questions: 1Answers: 2,586
    Answer ✓

    You can use the formButtons to do that - this example here should get you going.

    Colin

  • montoyammontoyam Posts: 568Questions: 136Answers: 5

    perfect:

                    buttons: [
                        { extend: 'create', editor: SubmissionsEditor },
                        {
                            extend: 'edit',
                            text: 'Edit/View',
                            editor: SubmissionsEditor,
                            formButtons: {
                                text: function () {
                                    var selected = SubmissionsTable.row({ selected: true });
    
                                    if (selected.data().Submissions.ResolutionMethodID == 0) {
                                        return 'Update';
                                    } else {
                                        return 'Close';
                                    }
                                },
    
                                action: function () {
                                    var selected = SubmissionsTable.row({ selected: true });
                                    if (selected.data().Submissions.ResolutionMethodID == 0) {
                                        this.submit();
                                    } else {
                                        this.close();
                                    }
                                }
                            }
                        }
    
                    ]
    
This discussion has been closed.