jquery easyui datagrid 如何批量添加???

bb5736 2014-05-26 08:18:04
appendRow默认只能添加一行,我想点击添加按钮,能直接显示五个空白行编辑???求教各位大湿
...全文
193 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
bb5736 2014-05-27
  • 打赏
  • 举报
回复
引用 2 楼 longtian1213 的回复:
你做个for循环呗!每循环一次添加一行,想添加多少就循环多少次!
求教代码????
bb5736 2014-05-27
  • 打赏
  • 举报
回复
太感谢了!!!!
S117 2014-05-27
  • 打赏
  • 举报
回复
引用 3 楼 bb5736 的回复:
[quote=引用 2 楼 longtian1213 的回复:] 你做个for循环呗!每循环一次添加一行,想添加多少就循环多少次!
求教代码????[/quote]

<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>Context Menu on DataGrid - jQuery EasyUI Demo</title>
	<link rel="stylesheet" type="text/css" href="../../themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="../../themes/icon.css">
	<link rel="stylesheet" type="text/css" href="../demo.css">
	<script type="text/javascript" src="../../jquery.min.js"></script>
	<script type="text/javascript" src="../../jquery.easyui.min.js"></script>
</head>
<body>
	<h2>Context Menu on DataGrid</h2>
	<p>Right click on the header of DataGrid to display context menu.</p>
	<div style="margin:20px 0;"></div>
	<table id="dg"></table>
	<script type="text/javascript">
		$(function(){
			$('#dg').datagrid({
				url: 'datagrid_data1.json',
				method: 'get',
				title: 'Context Menu on DataGrid',
				iconCls: 'icon-save',
				width: 700,
				height: 250,
				fitColumns: true,
				singleSelect: true,
				columns:[[
					{field:'itemid',title:'Item ID',width:80},
					{field:'productid',title:'Product ID',width:120},
					{field:'listprice',title:'List Price',width:80,align:'right'},
					{field:'unitcost',title:'Unit Cost',width:80,align:'right'},
					{field:'attr1',title:'Attribute',width:250},
					{field:'status',title:'Status',width:60,align:'center'}
				]],
				toolbar:[{
					iconCls: 'icon-add',
					handler:function(){
						for(var i=0;i<5;i++){
							$('#dg').datagrid('appendRow',{
								itemid: '',
								productid: '',
								listprice: '',
								unitcost:'',
								attr1:'',
								status:''
							});							
						}
					}
				}]
			});
		});
	</script>
</body>
</html>
S117 2014-05-26
  • 打赏
  • 举报
回复
你做个for循环呗!每循环一次添加一行,想添加多少就循环多少次!
loveunittesting 2014-05-26
  • 打赏
  • 举报
回复
直接给他5个空数据不久玩了吗

81,090

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧