Bhargavi Mahal
14 posts
Registered:
16 Dec 2020
03 Aug 2022
Link to this post
Hello Mason,
Thank you for posting your query.
The above functionality can be possible with some custom code. Please make necessary changes.
function disableButton(gridFieldName, numberofRecords){
var grid = tpc.find(gridFieldName);
if(grid !== null){
if(numberofRecords >= 1){
$("#gridFieldName_element a.k-button.k-grid-tpcadd").addClass('k-state-disabled'); //instead of gridFieldName_element place the id associated to the grid
}
else{
$("#gridFieldName_element a.k-button.k-grid-tpcadd").removeClass('k-state-disabled'); //instead of gridFieldName_element place the id associated to the grid
}
}
else{
console.error("Grid" + gridFieldName + "not found");
}
}
$(document).on("tpc:ready", function (event, tpcObject) {
tpc.forms[0].gridFieldName.get_grid().bind("dataBound",function(e){ //instead of gridFieldName use the field name associated to the grid
var length = tpc.forms[0].gridFieldName.get_grid().dataSource.data().length; //instead of gridFieldName use the field name associated to the grid
disableButton("gridFieldName",length); //instead of gridFieldName use the field name associated to the grid
});
disableButton("gridFieldName",length); //instead of gridFieldName use the field name associated to the grid
});
Please try this code and let us know if you have any questions.
Thank you,
Regards,
Bhargavi Mahal.