This repository is not really maintained, but kept here for history and fun.
gii-sortable.js v1.0.0
gii-sortable is a jQuery extension to easilly make <table> DOM
objects clickable and resortable, without having to render the page
again.
<table class="sortable">
<tr>
<th>Points</th>
<th>Name</th>
<th>Age</th>
</tr>
<tr>
<td>10</td>
<td data-sortable-value="Scott, Adam">Adam Scott</td>
<td>39</td>
</tr>
<tr>
<td>15</td>
<td data-sortable-value="Waters, Louice">Louice Waters</td>
<td>19</td>
</tr>
<tr>
<td>20</td>
<td data-sortable-value="Place, Mike">Mike Place</td>
<td>23</td>
</tr>
</table>
gii-sortable.js is a jQuery plugin. First of all, make sure that you have jQuery on your page. If not, put this in your section. Secondly, you need to link to the gii-sortable.js plugin. Here is an example on how you can accomlish this (several other methods exist):
<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
<script src="path/to/gii-sortable.js" type="text/javascript"></script>
let options = {
// Add options here
};
$('.sortable').sortable(options);
Options can be passed via data attributes or JavaScript. For data attributes, prepend the option name to data-, example: data-sortable-value=4000.
| Name | type | default | description |
|---|---|---|---|
| clickables | string | th | Header column 'cell' |
| resortables | string | tr | 'rows' of sortables |
| columns | string | td | 'cells' of sortables |
| class-clickable | string | clickable |
Class added to each header column cell. |
| sortable-default-order | string | asc |
[apply to clickables] Sort order on first click on this column. Set to asc for ascending or desc for descending. |
| sortable-value | mixed |
[apply to columns] Value to sort by. If not set, sorting is done by cell text. See example above. |
https://codepen.io/familjenpersson/full/yGqKrR
Created with joy by Jonas Persson @ Getskär IT Innovation 2014. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
- 1.0.0 Getskär March 14th, 2014.
- Initial commit.