Hide/show a button when editing a grid row

Hi,

I created grid in TypeScript. When I doubleclick a grid row, I can edit the row. However, I want to show a save button when I am editing the row and hide the button when I exit the edit mode. Is it achievable?   

Thank you,

1 Reply 1 reply marked as answer

SM Shalini Maragathavel Syncfusion Team July 3, 2020 01:35 PM UTC

Hi Muzaffer Birben, 
Thanks for contacting Syncfusion support. 
Based on your query .We can achieve your requirement by using actionBegin (with requestType as ‘beginEdit’ or ‘add’)  and actionComplete (with requestType as ‘save’) event of Grid.  
Here we can show and hide the external button based on Grid edit state. Please find the code example for your reference. 
[code example] 
 
actionBegin: function(args: EditEventArgs) { 
    if (args.requestType === "beginEdit" || args.requestType === "add") { 
       
      document.getElementsByClassName("button")[0].classList.add("show"); 
      document.getElementsByClassName("button")[0].classList.remove("hide"); 
    } 
  }, 
  actionComplete: function(args: EditEventArgs) { 
    if (args.requestType === "save") { 
      document.getElementsByClassName("button")[0].classList.remove("show"); 
      document.getElementsByClassName("button")[0].classList.add("hide"); 
    } 
  } 
}); 
grid.appendTo("#Grid"); 
document.getElementById('btn').addEventListener('click', function(e){ 
   
  grid.endEdit(); 
}) 
In the above code example , we have saved the edited records by using ‘endEdit()’ method of Grid while clicking the external button. 
Please check below sample and documentation for your reference. 
API documentation : 
Let us know if you have any concerns. 
Regards, 
Shalini M. 


 


Marked as answer
Loader.
Up arrow icon