NexaDom adalah library JavaScript yang kuat untuk menangani rendering data dinamis, pemfilteran, dan paginasi dalam aplikasi web. Library ini menyediakan cara yang efisien untuk mengelola dan menampilkan dataset besar dengan fitur seperti virtual scrolling, lazy loading, dan data chunking.
import NexaDom from './NexaDom.js';
const options = {
elementById: 'myList',
search: 'searchInput',
pagination: 'paginationContainer',
order: 10
};
const nexaDom = new NexaDom(options);
Opsi | Type | Nilai Default | Deskripsi |
---|---|---|---|
elementById | String | Wajib | ID dari elemen container |
search | String | null | ID of search input element |
pagination | String | null | ID of pagination container |
order | Number | 10 | Items per page |
sortBy | String | null | Field to sort by |
sortOrder | String | 'ASC' | Sort order ('ASC' or 'DESC') |
Mengatur data baru untuk instance
nexaDom.setData([
{ id: 1, name: "Item 1" },
{ id: 2, name: "Item 2" }
]);
Gets data by ID
const item = nexaDom.getData(1);
Filters data by key and value
nexaDom.filterKey('category', 'books');
Sorts data by specified field
nexaDom.sort('ASC', 'name');
Adds new data to existing dataset
nexaDom.addData(newItems, true);
Cleans up and removes instance
nexaDom.destroy();
NexaDom supports template filters using the pipe syntax:
{set.property|filter1|filter2}
NexaDom provides built-in pagination with the following features:
For large datasets, NexaDom automatically implements virtual scrolling to improve performance.
Images and heavy content are loaded only when they enter the viewport.
Large datasets are automatically split into manageable chunks for better performance.
Event Name | Description |
---|---|
dataReloaded | Fired when data is successfully reloaded |
dataReloadError | Fired when data reload fails |
document.addEventListener('dataReloaded', (event) => {
console.log('Data reloaded:', event.detail);
});
<div id="myList">
<script type="text/template" data-template="list">
<div class="item">
<h3>{set.title}</h3>
<p>{set.description}</p>
</div>
</script>
</div>
<div id="pagination"></div>
<script>
const nexaDom = new NexaDom({
elementById: 'myList',
pagination: 'pagination',
order: 10
});
nexaDom.setData([
{ title: 'Item 1', description: 'Description 1' },
{ title: 'Item 2', description: 'Description 2' }
]);
</script>
<input type="text" id="search" placeholder="Search...">
<select id="categoryFilter">
<option value="all">All Categories</option>
<option value="books">Books</option>
<option value="electronics">Electronics</option>
</select>
<div id="productList">
<script type="text/template" data-template="list">
<div class="product">
<h3>{set.name}</h3>
<p>Category: {set.category}</p>
</div>
</script>
</div>
<script>
const nexaDom = new NexaDom({
elementById: 'productList',
search: 'search',
filter: 'categoryFilter',
filterBy: 'category',
searchableFields: ['name', 'category']
});
</script>