|
@@ -231,7 +231,7 @@ function() {
|
|
|
i.ajax_success(i.ajax_data),
|
|
|
t(),
|
|
|
void("function" == typeof e ? e() : "");
|
|
|
- if ("string" != typeof i.ajax_url || "" === i.ajax_url) return i.outLog("请求表格数据失败!参数[ajax_url]配制错误", "error"),
|
|
|
+ if ("string" != typeof i.ajax_url || "" === i.ajax_url) return i.outLog("请求表格数据失败!参数[ajax_url]配制错误", "warn"),
|
|
|
t(),
|
|
|
void("function" == typeof e ? e() : "");
|
|
|
var s = $.extend({},
|
|
@@ -260,6 +260,109 @@ function() {
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
+ insertRow: function(e, obj) {
|
|
|
+ function a(t) {
|
|
|
+ var a, o, s, c, d, v = "";
|
|
|
+ var rad = Math.random();
|
|
|
+ d += '<tr class="trAdd" cache-key="' + rad + '">',
|
|
|
+ $.each(i.columnData,
|
|
|
+ function(e, i) {
|
|
|
+ a = i.key,
|
|
|
+ s = i.template,
|
|
|
+ c = "function" == typeof s ? s(t[a], t) : t[a],
|
|
|
+ o = i.align ? 'style="text-align:' + i.align + '"': "",
|
|
|
+ v = null!=c && "function" != typeof s ? ' title="' + c + '"': "",
|
|
|
+ d += "<td " + o + v + ">" + (null==c?"":c) + "</td>"
|
|
|
+ }),
|
|
|
+ d += "</tr>";
|
|
|
+ // 更新缓存数据
|
|
|
+// var newCacheData = {};
|
|
|
+// $.each(i.cacheData,
|
|
|
+// function(idx, tempObj) {
|
|
|
+// newCacheData[(parseInt(idx)+1)] = tempObj;
|
|
|
+// }),
|
|
|
+// i.cacheData = newCacheData;
|
|
|
+ // 获取json对象长度
|
|
|
+ var jsonLength = 0;
|
|
|
+ for(var item in i.cacheData){
|
|
|
+ jsonLength++;
|
|
|
+ }
|
|
|
+ if(jsonLength == 0) {
|
|
|
+ r.html(d);
|
|
|
+ } else {
|
|
|
+ $("#"+i.gridManagerName+" tbody tr:eq(0)").before(d);
|
|
|
+ }
|
|
|
+ i.cacheData[rad] = obj;
|
|
|
+ i.resetTd(n, !1);
|
|
|
+ "function" == typeof e ? e() : "";
|
|
|
+ if(i.supportCheckbox) {
|
|
|
+ $(r).children().each(function(){
|
|
|
+ var trObj = this;
|
|
|
+ var inputChk = $(trObj).find("input[type='checkbox']");
|
|
|
+ $(trObj).click(function(){
|
|
|
+ var chkFlg = $(inputChk).prop("checked");
|
|
|
+ $(inputChk).prop("checked", !chkFlg);
|
|
|
+ });
|
|
|
+ $(inputChk).parent().click(function(){
|
|
|
+ window.event.cancelBubble=true;
|
|
|
+ });
|
|
|
+
|
|
|
+ });
|
|
|
+ };
|
|
|
+ }
|
|
|
+ var i = this,
|
|
|
+ n = $('table[grid-manager="' + i.gridManagerName + '"]'),
|
|
|
+ r = $("tbody", n);
|
|
|
+ a(obj);
|
|
|
+ },
|
|
|
+ deleteRow: function(e, obj) {
|
|
|
+ var i = this,
|
|
|
+ n = $('table[grid-manager="' + i.gridManagerName + '"]'),
|
|
|
+ r = $("tbody", n);
|
|
|
+ // 更新缓存数据
|
|
|
+ delete this.cacheData[$(obj).closest("tr").attr("cache-key")];
|
|
|
+ // 删除当前行
|
|
|
+ $(obj).closest("tr").remove();
|
|
|
+ },
|
|
|
+ updateRow: function(e, dataObj, linkObj) {
|
|
|
+ function a(t, x) {
|
|
|
+ var a, o, s, c, d, v = "";
|
|
|
+ var rad = Math.random();
|
|
|
+ $.each(i.columnData,
|
|
|
+ function(e, i) {
|
|
|
+ a = i.key,
|
|
|
+ s = i.template,
|
|
|
+ c = "function" == typeof s ? s(t[a], t) : t[a],
|
|
|
+ o = i.align ? 'style="text-align:' + i.align + '"': "",
|
|
|
+ v = null!=c && "function" != typeof s ? ' title="' + c + '"': "",
|
|
|
+ d += "<td " + o + v + ">" + (null==c?"":c) + "</td>"
|
|
|
+ });
|
|
|
+ var currTr = $(x).closest("tr");
|
|
|
+ var cacheKey = $(x).closest("tr").attr("cache-key");
|
|
|
+ i.cacheData[cacheKey] = t;
|
|
|
+ $(currTr).html(d);
|
|
|
+ i.resetTd(n, !1);
|
|
|
+ "function" == typeof e ? e() : "";
|
|
|
+ if(i.supportCheckbox) {
|
|
|
+ $(r).children().each(function(){
|
|
|
+ var trObj = this;
|
|
|
+ var inputChk = $(trObj).find("input[type='checkbox']");
|
|
|
+ $(trObj).click(function(){
|
|
|
+ var chkFlg = $(inputChk).prop("checked");
|
|
|
+ $(inputChk).prop("checked", !chkFlg);
|
|
|
+ });
|
|
|
+ $(inputChk).parent().click(function(){
|
|
|
+ window.event.cancelBubble=true;
|
|
|
+ });
|
|
|
+
|
|
|
+ });
|
|
|
+ };
|
|
|
+ }
|
|
|
+ var i = this,
|
|
|
+ n = $('table[grid-manager="' + i.gridManagerName + '"]'),
|
|
|
+ r = $("tbody", n);
|
|
|
+ a(dataObj, linkObj);
|
|
|
+ },
|
|
|
checkMenuPageAction: function() {
|
|
|
var e = this,
|
|
|
t = $('.grid-menu[grid-master="' + e.gridManagerName + '"]');
|
|
@@ -1297,7 +1400,7 @@ function() {
|
|
|
0 === arguments.length ? (r = "init", o = {},
|
|
|
s = void 0) : 1 === arguments.length && "string" == typeof arguments[0] && "init" == typeof arguments[0] ? (r = arguments[0], o = {},
|
|
|
s = void 0) : 1 === arguments.length && "string" == typeof arguments[0] && "init" != typeof arguments[0] ? (r = arguments[0], o = void 0, s = void 0) : 1 === arguments.length && $.isPlainObject(arguments[0]) ? (r = "init", o = arguments[0], s = void 0) : 1 === arguments.length && "function" == typeof arguments[0] ? (r = "init", o = void 0, s = arguments[0]) : 2 === arguments.length && "string" == typeof arguments[0] && "function" == typeof arguments[1] ? (r = arguments[0], o = arguments[1], s = void 0) : 2 === arguments.length && "string" == typeof arguments[0] && "function" != typeof arguments[1] ? (r = arguments[0], o = arguments[1], s = void 0) : 2 === arguments.length && $.isPlainObject(arguments[0]) && "function" == typeof arguments[1] ? (r = "init", o = arguments[0], s = arguments[1]) : 2 === arguments.length && "string" == typeof arguments[0] && "boolean" == typeof arguments[1] ? (r = arguments[0], o = arguments[1], s = void 0) : 3 === arguments.length && (r = arguments[0], o = arguments[1], s = arguments[2]);
|
|
|
- var c = ["init", "setSort", "get", "getCheckedTr", "showTh", "hideTh", "exportGridToXls", "getLocalStorage", "resetTd", "setQuery", "refreshGrid", "getRowData", "clear"];
|
|
|
+ var c = ["init", "setSort", "get", "getCheckedTr", "showTh", "hideTh", "exportGridToXls", "getLocalStorage", "resetTd", "setQuery", "refreshGrid", "getRowData", "clear","insertRow","deleteRow","updateRow"];
|
|
|
if (c.indexOf(r) === -1) throw new Error("GridManager Error:方法调用错误,请确定方法名[" + r + "]是否正确");
|
|
|
var d;
|
|
|
if ("init" == r) {
|