Datatable from markup
# |
First Name |
Last Name |
Language |
1 |
Mark |
Otto |
CSS |
2 |
Jacob |
Thornton |
Javascript |
3 |
Stu |
Dent |
HTML |
4 |
Brosef |
Stalin |
HTML |
Usage
{% highlight js %}
nwt.one('#mytable1').plug('Datatable');
{% endhighlight %}
JSON Datatable
Usage
{% highlight js %}
nwt.one('#mytable2').plug('Datatable', {
columns: [{name:'bbq?', key: 'one'}, 'two', 'three'],
data: [
{one: 'bbq', two: 'ketchup', three: 'mustard'},
{one: 'dog', two: 'cat', three: 'raining'},
{one: 'Dave', two: 'Logan', three: 'Tony'}
]
})
// Click on a row to retreive the data that populated it
nwt.one('#mytable2').on('click', function(e){
alert('Row data: ' + JSON.stringify(e.target.getPluginData()))
}, 'td')
{% endhighlight %}
IO Datatable
Usage
{% highlight js %}
nwt.one('#mytable3').plug('Datatable', {
columns: ['one', 'two', 'three'],
data: nwt.io('/nwt/jekyll/jsondata.txt')
});
// By default we fetch via post, but it's easy to override
nwt.one('#mytable3').plug('Datatable', {
columns: ['one', 'two', 'three'],
data: nwt.io('/nwt/jekyll/jsondata.txt'),
fetch: function(io, sort, dir) {
io.get('sort=' + sort + '&dir=' + dir);
}
});
{% endhighlight %}