cannot create a new row after calling editor preopen function

cannot create a new row after calling editor preopen function

Khalid TeliKhalid Teli Posts: 251Questions: 71Answers: 0

I am calling an editor`` preOpen function to disable the inline editing of row if value for column status= confirmed. using :

  editorMain.on( 'preOpen', function ( e, mode, action ) {
  var getStatus = tablepromotions.row( editorMain.modifier().row).data();
  console.log(getStatus.status)

  if (getStatus.status == 'CONFIRMED') {
           alert("You cannot Edit confirmed Agreements");
    return false;
  } else{     
  }

} );

It is working perfectly fine. However , when I want to create a new row it gives me error Cannot read property 'row' of nullfor this line var getStatus = tablepromotions.row( editorMain.modifier().row).data();

I assume that when I am trying to create a new row, preOpen editor function looks for the row id which is NULL when creating a new row and hence giving the error .

How can I overcome this?

Thank you

This question has an accepted answers - jump to answer

Answers

  • Khalid TeliKhalid Teli Posts: 251Questions: 71Answers: 0
    edited November 2020

    Just an update, I found away to do it by disabling each field separately by:

      if (getStatus.status == 'CONFIRMED') {
    
                editorMain.field( 'status' ).disable();
                             alert("You cannot Edit confirmed Agreements");
      }  
    

    However, it will be better if I can disable full row once rather than doing it for each field separately

    In addition to this , if I call the function when editor is open rather than preOpen does the trick

  • colincolin Posts: 15,237Questions: 1Answers: 2,599
    Answer ✓

    The best option would be to check the parameters to preOpen. You could either check the second one, mode, to tell if you're in form (main) or inline. But you could always use the third, action, and only do your check if it's edit,

    Colin

  • Khalid TeliKhalid Teli Posts: 251Questions: 71Answers: 0

    @colin Thank you very much. That helped

This discussion has been closed.