๐งฉ Overview
In Joget, the Spreadsheet form element (powered by Handsontable) is perfect for managing tabular data inside forms.
However, it doesnโt natively provide built-in row-level delete buttons or a convenient add row feature.
In this guide, weโll learn how to:
โ
Add a delete button to each row in a Joget Spreadsheet.
โ
Create a separate โAdd Rowโ button that dynamically inserts new rows.
โ
Keep the entire implementation simple, secure, and fully functional.
โ๏ธ How It Works
๐ก The approach uses a custom column renderer and a jQuery button event:
- The custom renderer injects a Delete button in a column cell.
- The button calls
hot.alter("remove_row", row)to delete that row. - A separate Add Row button triggers
hot.alter("insert_row_below")to insert a new row at the bottom. - Both actions are performed dynamically without reloading the form.
๐ง Important:
- Set the spreadsheet column format type to
Custom. - Paste the renderer script directly in the custom field configuration.
- Avoid adding any extra comments inside the
rendererfunction (to prevent Joget parser issues).
๐ป Full Code
<!-- ๐น Place this inside your Spreadsheet column (Format Type: Custom) -->
{ {
renderer: function (instance, td, row, col, prop, value, cellProperties) {
td.innerHTML = "<button type='button' class='eaction'>#i18n.ocs_delete_btn#</button>";
td.style.textAlign = "center";
$(document).ready(function () {
let hot = FormUtil.getField("appointments_spreadSheet").data("hot");
let btn = td.querySelector(".eaction");
btn.onclick = function (e) {
e.preventDefault();
e.stopPropagation();
hot.alter("remove_row", row);
};
});
}
} }
// ๐น Add this script in a Custom HTML element below your Spreadsheet
$("#addRowBtn").on("click", function(e) {
e.preventDefault();
let hot = FormUtil.getField("appointments_spreadSheet").data("hot");
console.log({hot: hot});
if (!hot) {
console.error("Handsontable not initialized");
return;
}
try {
let lastRow = hot.countRows();
hot.alter("insert_row_below", lastRow);
} catch (err) {
console.error("Failed to add row", err);
}
});
<!-- ๐น Add Row Button -->
<button id="addRowBtn" class="btn btn-primary">
โ Add Row
</button>
๐ง Example Use Cases
โ
Employee Shift Planner โ Quickly add or remove shift rows.
โ
Project Task Tracker โ Manage task entries dynamically.
โ
Material Request Form โ Add/remove item rows on demand.
โ
Appointment List โ Delete canceled appointments instantly.
๐ ๏ธ Customization Tips
๐ก To change the delete button label:
Replace
#i18n.ocs_delete_btn#
with plain text (e.g., "Delete" or "Remove").
โ๏ธ To use a custom Spreadsheet ID:
Update this line:
FormUtil.getField("appointments_spreadSheet")
to match your spreadsheetโs field ID.
๐จ To style buttons:
Apply CSS in a Custom HTML element:
<style>
.eaction {
background-color: #e74c3c;
color: #fff;
border: none;
padding: 5px 10px;
border-radius: 6px;
}
#addRowBtn {
margin-top: 10px;
}
</style>
๐ Key Benefits
โ
User-friendly: Adds clear visual controls to manage rows.
โ๏ธ Lightweight: Uses only jQuery and built-in Joget APIs.
๐ Instant updates: No form reload needed.
๐งฉ Reusable: Works in any spreadsheet-based form.
๐ง Customizable: Easily adjust button text, color, or logic.
๐ Security Note
โ ๏ธ Ensure that delete actions are contextually safe โ
- Only use this feature for client-side data entry (not for record deletion in the database).
- If connected to backend records, validate all deletion logic on the server side before applying changes.


Top comments (0)