Hello,
Is there a possible way to give some validation messages when trying to delete a record/row in a grid?
Hi,
We have "Validate Record Data" trigger which will validate the record data. Configure it to run "Before Delete" timing.
Hope this helps.
Thanks,
Rajkumar
Hi Rajkumar,
I need to validate the grid row in client side using scripts or any other way preferred before submit to save.
Hello and Good Day,
You may try the script below:
<script>
$(function() {
//Add handler to all delete links
$('[id*="rbi_gridTable"]').each(function(index, element) { //Look through all grids and override the existing delete links in the page
$(this).find('.actionCol').each(function(index, element) { //actionCol element holds the delete link element
var delLink = $(this).find('a').first();
if (delLink.length > 0) overrideDelete( delLink );
});
});
});
function onCreate(gridNo,gridRow) { //appended to the oncreate of the grid to override the link when a row is created
overrideDelete( $('#rbi_gridRow_'+gridNo+'_'+gridRow+' .actionCol').first().find('a').first() );
}
function overrideDelete(element) {
var clonedElement = $(element).clone(); //Clone the delete element to retain the onclick, needed if confirmation is true
$(element).attr('onClick','').on('click', function(){ //remove onclick of the original element and append your own
var x = confirm('Are you sure you want to delete this row?'); //check if the person really wants to delete the row
if (x) clonedElement.click(); //delete if he does
});
}
</script>
Required:
- add onCreate(##,@@); to your grid control's oncreate property.
You may then play around with what I did to suit your needs.
The main thing I did is to override the delete links' onclick to be able to append your own.
Hope that helps.