...
|
...
|
@@ -36,10 +36,13 @@ var grid = function(options) { |
|
|
grid.prototype = {
|
|
|
constructor: grid,
|
|
|
|
|
|
init: function(url) {
|
|
|
init: function(url, second) {
|
|
|
var g = this,
|
|
|
p = this.options;
|
|
|
|
|
|
|
|
|
p.url = url;
|
|
|
p.second = second;
|
|
|
g.grid = $(p.el);
|
|
|
g.grid.html(p.innerHtml);
|
|
|
g.table = $("table", g.grid);
|
...
|
...
|
@@ -76,7 +79,7 @@ grid.prototype = { |
|
|
if (typeof p.url == "string") {
|
|
|
g.ajax(_p);
|
|
|
} else {
|
|
|
g.__bodyClomun(p.url);
|
|
|
g.__bodyClomun(p.url, p.second);
|
|
|
}
|
|
|
|
|
|
}
|
...
|
...
|
@@ -206,8 +209,7 @@ grid.prototype = { |
|
|
total: data.totalPage,
|
|
|
page: data.page
|
|
|
});
|
|
|
g.__bodyClomun(data.list);
|
|
|
// setpage(res);
|
|
|
g.__bodyClomun(data.list, p.second);
|
|
|
},
|
|
|
complete: function(res) {
|
|
|
console.log("complete~~");
|
...
|
...
|
@@ -222,7 +224,7 @@ grid.prototype = { |
|
|
};
|
|
|
$.ajax(ajaxOptions);
|
|
|
},
|
|
|
__bodyClomun: function(rows) {
|
|
|
__bodyClomun: function(rows, second) {
|
|
|
var g = this,
|
|
|
p = this.options;
|
|
|
g.tbody.html("");
|
...
|
...
|
@@ -236,31 +238,37 @@ grid.prototype = { |
|
|
return (p.page - 1) * parseInt(p.rp);
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (rows.length > 0) {
|
|
|
for (var row in rows) {
|
|
|
|
|
|
var item = rows[row],
|
|
|
_h = "";
|
|
|
var num = _r_num() + _count;
|
|
|
|
|
|
item._num = _count;
|
|
|
item.rowid = "wqt_" + num + "_" + _count;
|
|
|
if (!item) continue;
|
|
|
_h += ('<tr >');
|
|
|
g.records.push(_count);
|
|
|
item.__index = _count;
|
|
|
g.rows.push(item);
|
|
|
$(p.columns).each(function(i, column) {
|
|
|
if (!column.hidden) {
|
|
|
//console.log(item, column);
|
|
|
_h += ('<td>');
|
|
|
_h += (g.__bodyCell(item, column));
|
|
|
_h += ('</td>');
|
|
|
}
|
|
|
})
|
|
|
_h += ('</tr>');
|
|
|
|
|
|
if (item[second] && item[second].length > 0) {
|
|
|
_h += g.__bodySecondClomun(item, item[second])
|
|
|
} else {
|
|
|
_h += ('<tr >');
|
|
|
$(p.columns).each(function(i, column) {
|
|
|
if (!column.hidden) {
|
|
|
_h += ('<td>');
|
|
|
_h += (g.__bodyCell(item, column));
|
|
|
_h += ('</td>');
|
|
|
}
|
|
|
})
|
|
|
_h += ('</tr>');
|
|
|
_count++;
|
|
|
}
|
|
|
|
|
|
_r.push(_h);
|
|
|
_count++;
|
|
|
g.tbody.html(_r.join(''));
|
|
|
}
|
|
|
} else {
|
...
|
...
|
@@ -274,13 +282,40 @@ grid.prototype = { |
|
|
g.tbody.html(_r.join(''));
|
|
|
}
|
|
|
},
|
|
|
__bodySecondClomun: function(row, second) {
|
|
|
var g = this,
|
|
|
p = this.options,
|
|
|
index = this.options.secondIndex;
|
|
|
var _r = '',
|
|
|
count = 0;
|
|
|
|
|
|
$.each(second, function(i, value) {
|
|
|
_r += '<tr>';
|
|
|
$(p.columns).each(function(i, column) {
|
|
|
if (!column.hidden && count < index) {
|
|
|
_r += ('<td rowspan="' + second.length + '">');
|
|
|
_r += (g.__bodyCell(row, column));
|
|
|
_r += ('</td>');
|
|
|
count++;
|
|
|
} else {
|
|
|
if (i >= index) {
|
|
|
_r += ('<td>');
|
|
|
_r += (g.__bodyCell(value, column));
|
|
|
_r += ('</td>');
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
_r += '</tr>';
|
|
|
});
|
|
|
|
|
|
return _r;
|
|
|
},
|
|
|
__bodyCell: function(row, col) {
|
|
|
var g = this,
|
|
|
p = this.options;
|
|
|
if (!row || !col) return "";
|
|
|
var value = col.name ? row[col.name] : null;
|
|
|
|
|
|
|
|
|
var content = "";
|
|
|
if (col.type) {
|
|
|
content = "<input type='" + col.type + "' name='" + col.name + "' class='wqt_checkbox' data-index='" + row.__index + "'>";
|
...
|
...
|
|