dojo的DataGrid2

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<style type="text/css">
			@import "dijit/themes/tundra/tundra.css";
			@import "dojo/resources/dojo.css";
			@import "dojox/grid/resources/tundraGrid.css";

		</style>
		<script type="text/javascript" src="dojo/dojo.js" djconfig="parseOnLoad:true"></script>
		<script>
            dojo.require("dojo.parser");
            dojo.require("dojo.data.ItemFileReadStore");
            dojo.require("dojox.grid.DataGrid");

		</script>
	</head>
	<body class="tundra">
		<h2>数据</h2>
		<div dojoType="dojo.data.ItemFileReadStore" jsId="wishStore" url="services/wish_list.json"></div>
		<table dojoType="dojox.grid.DataGrid" store="wishStore"  style ="width:350px;height:200px">
			<colgroup span = "1" noscroll = "true"></colgroup>
			<colgroup span = "5"></colgroup>
			<thead>
				<tr>
					<th field="wishId">wishId</th>
					<th field="description">description</th>
					<th field="size">size</th>
					<th field="origin">origin</th>
					<th field="wrapper">wrapper</th>
					<th field="shape">shape</th>
				</tr>
			</thead>
		</table>
	</body>
</html>
 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要在 Dojo Datagrid 中实现数据删除功能,可以按照以下步骤进行: 1. 在 Datagrid 中添加一个列,用于显示删除按钮。 2. 在该列中定义一个自定义单元格模板,用于显示删除按钮。 3. 在该模板中添加一个点击事件处理程序,以便在单击删除按钮时触发删除操作。 4. 在删除操作处理程序中获取要删除的数据行,并将其从数据存储中删除。 以下是一个简单的示例代码,演示如何在 Dojo Datagrid 中实现数据删除功能: ```javascript require(["dojo/_base/lang", "dojo/_base/declare", "dojo/data/ItemFileWriteStore", "dojox/grid/DataGrid", "dojo/domReady!"], function(lang, declare, ItemFileWriteStore, DataGrid){ var data = { identifier: "id", items: [ { id: 1, name: "John Doe", age: 32 }, { id: 2, name: "Jane Smith", age: 25 }, { id: 3, name: "Bob Johnson", age: 45 } ] }; var store = new ItemFileWriteStore({data: data}); var grid = new DataGrid({ structure: [ { name: "Name", field: "name", width: "200px" }, { name: "Age", field: "age", width: "100px" }, { name: "Delete", field: "id", width: "100px", formatter: function(id){ return "<button data-dojo-type='dijit/form/Button'>Delete</button>"; }, cellType: dojox.grid.cells.Cell, editable: false, onClick: function(evt){ var row = grid.getItem(evt.rowIndex); store.deleteItem(row); store.save(); } } ], store: store, rowSelector: "20px" }, "grid"); grid.startup(); }); ``` 在这个示例中,我们添加了一个名为“Delete”的列,用于显示删除按钮。我们定义了一个自定义单元格模板,用于显示一个具有“Delete”标签的按钮。我们还添加了一个事件处理程序,以便在单击按钮时触发删除操作。在该处理程序中,我们获取要删除的数据行,并将其从数据存储中删除。最后,我们使用 ItemFileWriteStore 作为数据存储,并将其与 Datagrid 组件一起使用。 注意:该示例代码仅供参考,具体实现需要根据具体情况进行调整。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值