Showing results for 
Search instead for 
Do you mean 
Community Home Request Access Read Blogs Share Your Ideas Search Community View My Settings
Reply
Copper Elite Contributor
Posts: 47
Registered: ‎04-26-2009

How to disable "edit" and "delete" links in a data grid?

I am using a datagrid to display product lines in a quote. When the quote is finalised I  want to make the grid completely read-only i.e. disable the "Edit" and "delete" column links entirely. Is this possible?

 

Highlighted
Copper Elite Contributor
Posts: 47
Registered: ‎04-26-2009

Re: How to disable "edit" and "delete" links in a data grid?

Found a way to do this using jQuery:

 

 - picking up the value of "finalised" from a field on the form.

 - overriding the delete confirm message so it doesn't show.

 - preventing the "edit" and "delete" links in the grid from working by removing the href attribute on anchor tags in the grid. Also fade the colour after the click attempt.

 - display a message to the user.

 

 

var script = @"require(['dojo/ready', 'Sage/Utility'],
function(ready, utility){ ready(function() { 

  var finalised = $('#TabControl_element_QuoteProducts_element_view_QuoteProducts_QuoteProducts_Finalised').val();

  if (finalised == 'True')
  {
    window.confirm = function() {};
    $('#TabControl_element_QuoteProducts_element_view_QuoteProducts_QuoteProducts_grdrrigationQuoteItems a').click(function () {
      alert('Products cannot be edited on a finalised quote.');
      $(this).fadeTo('fast',.5).removeAttr('href');
    }); 
  }
 });
});";
ScriptManager.RegisterStartupScript(this, GetType(), new Guid().ToString(), script, true);