π§© 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)