var value = $("table[id='" + this._id + "'] tfoot tr td input").val();
if (!isNaN(parseInt(value))) {
if (parseInt(value) <= _op.settings.totalpage) _op.createTableBody(parseInt(value));
else alert("超出页总数");
} else alert("请输入数字");
});
},
//添加异步ajax事件
getAjaxDate: function (url, parms) {
//定义一个全局变量来接受$post的返回值
var result;
//用ajax的同步方式
$.ajax({
url: url,
async: false,
//改为同步方式
data: parms,
success: function (data) {
result = data;
}
});
return result;
}
}
$.fn.grid = function (options) {
var grid = new dataGrid(this, options);
return this.each(function () {
grid.init();
});
}
})
html调用
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<script src="jquery-1.8.0.min.js"></script>
<link rel="stylesheet" type="text/css" href="style.css">
<script src="pagetion.js"></script>
<script type="text/javascript">
$(function(){
$("#dg").grid({
id:"dg",
url:"data.json",
columns: [
{field:'ck',checkbox:true},
{ field: 'ID', title: '编号', width:100, align: 'center'},
{ field: 'name', title: '名称', width: 150, align: 'left' },
{ field: 'descrtion', title: '描述', width: 350, align: 'left' },
{ field: 'Price', title: '价格', width: 100, align: 'left' }
],
isoddcolor:false,
pagination:true,
searchnation:true,
pagesize:5
});
});
</script>
</head>
<body>
<form id="form1">
<table id="dg">
</table>
</form>
</body>
</html>本文只是为大家提供了一个框架、思路,如何将这些知识点串连在一起,还需要大家认真的学习研究,动手创建一个属于自己的jquery表格插件。










