Skip to content

Commit

Permalink
Move row rendering into a separate method renderRow.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lauris committed Sep 11, 2014
1 parent 5769cd9 commit a5dfd61
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 29 deletions.
34 changes: 20 additions & 14 deletions dist/sensei-grid.js
Expand Up @@ -9,6 +9,7 @@

var plugin = this,
defaults = {
emptyRow: true,
sortable: true,
tableClass: "" // table table-bordered table-condensed
};
Expand Down Expand Up @@ -597,24 +598,29 @@

var $tbody = $("tbody", plugin.$el);
_.each(plugin.data, function (item) {
var tr = document.createElement("tr");
_.each(plugin.columns, function (column) {
var td = document.createElement("td");
var div = document.createElement("div");
var tr = plugin.renderRow(item);
$tbody.append(tr);
});
};

if (_.has(item, column.name)) {
$(div).text(item[column.name]);
}
plugin.renderRow = function (item) {
var tr = document.createElement("tr");
_.each(plugin.columns, function (column) {
var td = document.createElement("td");
var div = document.createElement("div");

$(td).data("column", column.name);
$(td).data("type", column.type || "string");
$(td).data("editor", column.editor || "BasicEditor");
if (_.has(item, column.name)) {
$(div).text(item[column.name]);
}

td.appendChild(div);
tr.appendChild(td);
});
$tbody.append(tr);
$(td).data("column", column.name);
$(td).data("type", column.type || "string");
$(td).data("editor", column.editor || "BasicEditor");

td.appendChild(div);
tr.appendChild(td);
});
return tr;
};

plugin.renderBaseTable = function () {
Expand Down

0 comments on commit a5dfd61

Please sign in to comment.