forked from ontoportal/ontoportal_web_ui
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add sort parameter to option component
- Loading branch information
1 parent
b4b390b
commit a10f6de
Showing
3 changed files
with
29 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
%table.table-content{id: @id ,class: stripped_class + ' ' + borderless_class + ' ' + layout_fixed_class + ' ' + mini_class + ' ' + outline_class} | ||
%thead | ||
= header | ||
%tbody{id: "#{@id}_table_body"} | ||
- rows.each do |row| | ||
= row | ||
= content | ||
%div{'data-controller': 'table-component'} | ||
%table.table-content{id: @id ,'data-sort': @sort.to_s,class: stripped_class + ' ' + borderless_class + ' ' + layout_fixed_class + ' ' + mini_class + ' ' + outline_class} | ||
%thead | ||
= header | ||
%tbody{id: "#{@id}_table_body"} | ||
- rows.each do |row| | ||
= row | ||
= content |
19 changes: 19 additions & 0 deletions
19
app/components/table_component/table_component_controller.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import {Controller} from "@hotwired/stimulus" | ||
import DataTable from 'datatables.net-dt'; | ||
|
||
|
||
// Connects to data-controller="table-component" | ||
export default class extends Controller { | ||
connect(){ | ||
let table_component | ||
table_component = this.element.childNodes[1] | ||
if (table_component.dataset.sort === 'true'){ | ||
let table = new DataTable('#'+table_component.id, { | ||
paging: false, | ||
info: false, | ||
searching: false, | ||
autoWidth: true | ||
}); | ||
} | ||
} | ||
} |