AutoSkill Dynamic JavaScript Table with Sorted Data and Event Listeners
Generates a dynamic HTML table where data objects are sorted by a header array. Includes functionality to add rows via a button in the last row, inserting new rows above the button. New rows support input/select elements with event listeners attached via JavaScript (not inline HTML).
install
source · Clone the upstream repo
git clone https://github.com/ECNU-ICALK/AutoSkill
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ECNU-ICALK/AutoSkill "$T" && mkdir -p ~/.claude/skills && cp -r "$T/SkillBank/ConvSkill/english_gpt4_8_GLM4.7/dynamic-javascript-table-with-sorted-data-and-event-listeners" ~/.claude/skills/ecnu-icalk-autoskill-dynamic-javascript-table-with-sorted-data-and-event-listene && rm -rf "$T"
manifest:
SkillBank/ConvSkill/english_gpt4_8_GLM4.7/dynamic-javascript-table-with-sorted-data-and-event-listeners/SKILL.mdsource content
Dynamic JavaScript Table with Sorted Data and Event Listeners
Generates a dynamic HTML table where data objects are sorted by a header array. Includes functionality to add rows via a button in the last row, inserting new rows above the button. New rows support input/select elements with event listeners attached via JavaScript (not inline HTML).
Prompt
Role & Objective
Act as a Frontend Engineer. Write JavaScript to generate a dynamic HTML table based on a provided header array and data array.
Operational Rules & Constraints
- Data Formatting: Accept a header array (e.g.,
) and a data array of objects. For each data object, reorder properties so those in the header array appear first, in that specific order. Append any remaining properties that are not in the header array afterwards in their default order.['id', 'name'] - Table Structure: Generate the
based on the header array and thethead
based on the formatted data.tbody - Dynamic Row Addition: The
must end with a special row containing a single cell (withtbody
matching the total column count) and a button. Clicking this button must insert a new data row immediately before this button row.colSpan - Editable Cells: New rows may contain
or<input>
elements.<select> - Event Handling: CRITICAL: Do not use inline HTML attributes (e.g.,
) for event handling. You must use JavaScriptonchange="func()"
to attachaddEventListener
orchange
events to these elements to capture values dynamically.input
Anti-Patterns
- Do not use inline event handlers like
.onchange - Do not append new rows to the very end of the tbody (must be above the button row).
- Do not discard properties that are not present in the header array.
Interaction Workflow
- Receive header array and data array.
- Format data objects according to the header order.
- Generate the table structure.
- Implement the button logic to insert rows with dynamic event listeners.
Triggers
- generate dynamic table with sorted data
- javascript table add row with event listeners
- format data according to header array
- insert row before button row
- dynamic table with inputs and selects