GRID JAVASCRIPT COMMON FUNCTIONS

Morris Muriuki Muthigani
74
0
others

09/23/2022 (1 year ago)


Disable a grid
function disableGrid(elementid) {
  return $("#" + elementid).find("input,button,textarea,select").attr("disabled", true);
}
Clear a grid
function clearGrid(gridId) {
	return $("#" + gridId ).clear();
}
Hide a grid column
function hideGridColumn(gridId, index) {
    $("#" + gridId).hideColumn(index);
    $("#" + gridId).disableValidation(index);
}
Show a grid column
function showGridColumn(gridId, index) {
    $("#" + gridId).showColumn(index);
    $("#" + gridId).enableValidation(index);
}
Check if a Grid column is empty
function isGridColumnEmpty (gridId, rowNo, columnNo) {
  if (!($("#" + gridId).getValue(rowNo, columnNo) != '')) {
    return [false, columnNo];
  }
  return [true, columnNo];
}
Enable a grid column
function enableGridColumn(gridId, gridColumnId) {
  let gridRows = $("#" + gridId).getNumberRows();
  
    for (i = 1; i <= gridRows; i++) {

        $("#form\\[" + gridId + "\\]\\[" +i+ "\\]\\[" + gridColumnId + "\\]").attr("disabled", false);
        
    }

}
function enableGridColumn(gridId, gridColumnId) {
  let numberOfGrid = $("#" + gridId).getNumberRows();
  
  for (let index = 1; index <= numberOfGrid; index++) { 

      $("#" + gridId).find("#"+ gridId +"-body").find("#form\\["+ gridId +"\\]\\[" + index + "\\]\\["+ gridColumnId +"\\]").prop("disabled", false);
  }
}
Disable a grid column
function disableGridColumn(gridId, gridColumnId) {
  let gridRows = $("#" + gridId).getNumberRows();
  
    for (i = 1; i <= gridRows; i++) {
        $("#form\\[" + gridId + "\\]\\[" +i+ "\\]\\[" + gridColumnId + "\\]").attr("disabled", true);
        
    }

}

Discussion (0)

Recent Blogs

Our Recent Blogs