jTable - jQuery Datagrid done right
To Use:
<div id="widgets"></div>
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
$("#widgets").jTable({
columns: [
{heading: "Column 1", attribute: "attribute_1"},
{heading: "Column 2", attribute: "attribute_2"},
{heading: "Column 3", attribute: "attribute_3"}
]
})
})
</script>
Options:
- identifierAttribute:
- Default:
"id"
- This attribute will be used to identify each record in the table.
- Default:
- singleColumnSearch:
- Default:
false
- Enable single column search for all searchable columns.
- Default:
- perPage:
- Default:
25
- The default number of items displayed per page.
- Default:
- perPageOptions:
- Default:
[25,50,100]
- The possible selections for the number of items displayed per page.
- Default:
- fullPagination:
- Default:
true
- Show page numbers.
- Default:
- ajaxInterval:
- Default:
250
- The amount of time (in ms) to wait for more user input before sending server request.
- Default:
- noItemsMsg:
- Default:
"No Records were found."
- The text displayed when no records are returned for the current query.
- Default:
- rowClass:
- Default:
""
- CSS classes to be added to each records table row. Multiple classes should be space separated.
- Default:
- width:
- Default:
""
- CSS width to be applied to the container.
- Default:
- indexUrl:
- Default:
""
- The URL where all query calls are sent.
- Default:
- viewLink:
- Default:
true
- Show the "View" link on each record.
- Default:
- viewUrl:
- Default:
"?id=:id:"
- The URL for the "View" link. The value of a records attributes can be substituted into the URL by using :attribute: (see the "Record URLs" section below).
- Default:
- inlineView:
- Default:
true
- Display the view in the table.
- Default:
- editLink:
- Default:
true
- Show the "Edit" link on each record.
- Default:
- editUrl:
- Default:
"edit?id=:id:"
- The URL for the "Edit" link. The value of a records attributes can be substituted into the URL by using :attribute: (see the "Record URLs" section below).
- Default:
- destroyLink:
- Default:
true
- Show the "Destroy" link on each record.
- Default:
- destroyUrl:
- Default:
"?id=:id:"
- The URL for the "Destroy" link. The value of a records attributes can be substituted into the URL by using :attribute: (see the "Record URLs" section below).
- Default:
- onDestroy:
- Default:
function(data){}
- Function to run when the destroy ajax call returns successful. The destroy ajax call's response is passed into the function.
- Default:
- destroyConfirmMsg:
- Default:
"Are you sure?"
- Message to use in confirmation before the destroy request is sent.
- Default:
- otherActions:
- Default:
[]
- An array of objects that are used to generate links thats are added to each records actions.
- Action options:
- title: This will be the text of the link
- All other attributes will be applied as HTML attributes of the link. The value of a records attributes can be substituted into each HTML attribute value by using :attribute: (see the "Record URLs" section below).
- Default:
- columns:
- Default:
[]
- An array of objects that are used to for generating the tables columns (see the "Column Options" section below).
- Default:
Record URLs
For Widget with attributes {id: 37, name: 'Thingy'}
/widgets/:id:?name=:name:
, will produce /widgets/37?name=Thingy
.
Column Options
- searchable:
- Default:
true
- Enable searching for this column
- Default:
- sortable:
- Default:
true
- Enable sorting for this column
- Default:
- dataType:
- Default:
"string"
- What type of attribute is this column (ex.
string
,boolean
).
- Default:
- trueValue:
- Default:
"True"
- The text displayed for a
true
value in aboolean
dataType column.
- Default:
- falseValue:
- Default:
"False"
- The text displayed for a
false
value in aboolean
dataType column.
- Default:
- columnClass:
- Default:
""
- CSS classes to be added to this column for each record. Multiple classes should be space separated.
- Default: