【发布时间】:2009-11-28 12:05:42
【问题描述】:
我在 Zend Framework 项目中遇到了一个简单的 dojo 数据网格。
我有一个可以显示的 mysql 表中的数据列表,但是我希望用户能够删除选定的行(并将它们从数据库中删除)。我正在使用来自Dojo DataGrid adding and deleting data 的示例。我的数据网格视图中的代码如下所示。
<div dojoType="dojo.data.ItemFileReadStore" jsId="skillstore" url="<?php echo $this->baseUrl()?>/skills/hist/<?php echo $this->histid;?>"></div>
<table id="skillgrid" jsId="skills" dojoType="dojox.grid.DataGrid" store="skillstore" style="height:300px;width:500px;">
<thead>
<tr>
<th field="skillid" hidden="true"></th>
<th width="auto" field="skill">Skills</th>
</tr>
</thead>
</table>
<div>
<button dojoType="dijit.form.Button" onclick="removeRows()" >Remove Selected Row</button>
<button dojoType="dijit.form.Button" onclick="addRow()">Add another skill</button>
</div>
我已经在视图脚本 captureStart 和 captureEnd 标记之间放置了用于删除行的代码。 removeRows() 的代码如下所示。
function removeRows(e){
var items = skillsgrid.selection.getSelected();
if(items.length){
dojo.forEach(items, function(selectedItem){
if(selectedItem !== null){
skillstore.deleteItem(selectedItem);
}//endif
});//end foreach
}//end if
}
我遇到的主要问题是,当我选择一行并单击按钮时,萤火虫抱怨说 Skillstore.deleteItem 不是一个函数。我还没有尝试从数据库中删除该条目。
任何指针将不胜感激。
【问题讨论】:
-
skillstore到底是什么?我看到它是表的store属性。我不太了解 Dojo - 那是否意味着它是自动初始化的?
标签: php zend-framework dojo