Skip to content

Commit

Permalink
More fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
jgauffin committed Feb 27, 2012
1 parent 0655dca commit 4fa8d8f
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 14 deletions.
21 changes: 21 additions & 0 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# v1.0.5

## Implemented all callbacks

https://github.com/jgauffin/Griffin.Table/wiki/Callbacks

## Storing JSON object on each row:

Each <tr> tag that is loaded through the plugin gets it's data/json stored using $().data() which means that you can use jQuery to load it at any time.

Example

alert($('#myTable tbody tr:first').data('griffin-table-data').FirstName + ' is the name of the first user');

## The odd class for TR styling is now configurable

$('#myTable').griffinTable({ style: { oddRowClass: 'myOdd' }});

## Added plain html/javascript examples

https://github.com/jgauffin/Griffin.Table/tree/master/Source/js/Examples
7 changes: 4 additions & 3 deletions Source/js/Examples/Callbacks.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<link rel="stylesheet" href="Styles/jquery-ui-1.8.16.custom.css">
<script type="text/javascript" src="scripts/jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="scripts/jquery-ui-1.8.16.custom.min.js"></script>
<script type="text/javascript" src="../../Plugin/jQuery.griffinTable.js"></script>
<script type="text/javascript" src="jQuery.griffinTable.js"></script>
<style type="text/css">
th { text-align: left; padding: 10px; }
td { border: 1px solid #f0f0f0; padding: 5px; }
Expand All @@ -14,7 +14,7 @@
</head>
<body>
<div id="middle">
<form id="mytable-form" action="">
<form id="mytable-form" action="http://localhost/griffintable/example.json" method="post">
</form>
<table id="mytable">
<thead>
Expand Down Expand Up @@ -43,6 +43,7 @@

$(function(){
$('table').griffinTable({
fetchAtStart: true,
callbacks: {
rowsLoaded: function() {
$('tr', $(this)).click(function(e) {
Expand All @@ -56,7 +57,7 @@
});

// simulate an ajax request.
$('table').griffinTable('loadData', exampleJson);
//$('table').griffinTable('loadData', exampleJson);
});
</script>
</body>
Expand Down
2 changes: 1 addition & 1 deletion Source/js/Examples/Index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<head>
<title>Table demo - Basic</title>
<script type="text/javascript" src="scripts/jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="../../Plugin/jQuery.griffinTable.js"></script>
<script type="text/javascript" src="../Plugin/jQuery.griffinTable.js"></script>
<style type="text/css">
th { text-align: left; }
#middle {width: 800px;}
Expand Down
2 changes: 1 addition & 1 deletion Source/js/Examples/ShowMorePager.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<link rel="stylesheet" href="Styles/jquery-ui-1.8.16.custom.css">
<script type="text/javascript" src="scripts/jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="scripts/jquery-ui-1.8.16.custom.min.js"></script>
<script type="text/javascript" src="../../Plugin/jQuery.griffinTable.js"></script>
<script type="text/javascript" src="../Plugin/jQuery.griffinTable.js"></script>
<style type="text/css">
th { text-align: left; }
#middle {width: 800px;}
Expand Down
10 changes: 10 additions & 0 deletions Source/js/Examples/example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
TotalRowCount: 5,
Rows:[
{Id: 1, FirstName: "Jonas1", LastName: "Gauffin", Age: 35},
{Id: 2, FirstName: "Jonas2", LastName: "Gauffin", Age: 35},
{Id: 3, FirstName: "Jonas3", LastName: "Gauffin", Age: 35},
{Id: 4, FirstName: "Jonas4", LastName: "Gauffin", Age: 35},
{Id: 5, FirstName: "Jonas5", LastName: "Gauffin", Age: 35}
]
}
3 changes: 2 additions & 1 deletion Source/js/Examples/styling.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<link rel="stylesheet" href="Styles/jquery-ui-1.8.16.custom.css">
<script type="text/javascript" src="scripts/jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="scripts/jquery-ui-1.8.16.custom.min.js"></script>
<script type="text/javascript" src="../../Plugin/jQuery.griffinTable.js"></script>
<script type="text/javascript" src="../Plugin/jQuery.griffinTable.js"></script>
<style type="text/css">
th { text-align: left; padding: 10px; }
td { border: 1px solid #f0f0f0; padding: 5px; }
Expand Down Expand Up @@ -43,6 +43,7 @@

$(function(){
$('table').griffinTable({
fetchAtStart: true,
callbacks: {
rowsLoaded: function() {
//initialize($(this));
Expand Down
18 changes: 10 additions & 8 deletions Source/js/Plugin/jQuery.griffinTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@
/** styles that should be applied to the table */
styles: { /** Class to append to odd rows, used by the default themeManger */
oddRowClass: 'odd',

/** Class to append to even rows, used by the default themeManager */
evenRowClass: ''
},

/** used to show debug output, default option uses the browser console */
Expand Down Expand Up @@ -120,7 +117,8 @@
pluginContext.settings.callbacks.fetchingRows.apply(pluginContext.$table[0], [pluginContext.form]);
var formData = pluginContext.form.serialize();
var url = pluginContext.form.attr('action');

var formMethod = pluginContext.form.attr('method');

var pos = pluginContext.$table.position();
var $overlay = $('<div style="background-color: grey;opacity: 0.5;">Loading</div>');
$('body').append($overlay);
Expand All @@ -131,10 +129,14 @@
width: pluginContext.$table.width() + "px",
height: pluginContext.$table.height() + "px"
});
$.get(url, formData, function (json) {
pluginContext.settings.callbacks.fetchedRows.apply(pluginContext.$table[0], [pluginContext.form, json]);
plugin.loadData(json);
$overlay.remove();
$.ajax(url, {
data: formData,
method: formMethod,
success: function (json) {
pluginContext.settings.callbacks.fetchedRows.apply(pluginContext.$table[0], [pluginContext.form, json]);
plugin.loadData(json);
$overlay.remove();
}
});

return false;
Expand Down
Binary file added nuget/Griffin.Table.1.0.5.nupkg
Binary file not shown.

0 comments on commit 4fa8d8f

Please sign in to comment.