roc*_*tar 1 dojo json zend-framework dojox.grid.datagrid
我有一个带有json数据存储区的dojo网格(mysql结果集转换为json格式).目前我的网格显示5列,如下图所示:

我有一个名为'Action'的列.此"操作"列下的行应包含带有超链接的按钮或图像(编辑图标,删除图标),例如edit.php?id = 1用于编辑,或者delete.php?id = 1用于删除.这是我的dojo网格代码:
<span dojoType="dojo.data.ItemFileReadStore" data-dojo-id="studentsStore" url="http://localhost/newsmis/public/studentManagement/student/fetchdata/data/1"></span>
<table dojoType="dojox.grid.DataGrid" id="studentsGrid" data-dojo-id="studentsGrid" columnReordering="true" sortFields="['idstudents','first_name','middle_name','last_name']" store="studentsStore" clientSort="true" selectionMode="single" rowHeight="25" noDataMessage="<span class='dojoxGridNoData'>No students found</span>">
<thead>
<tr>
<th field="idstudents" width="20%">Student ID</th>
<th field="first_name" width="20%">First Name</th>
<th field="middle_name" width="20%">Middle Name</th>
<th field="last_name" width="20%">Last Name</th>
<th field="action" width="20%">Action</th>
</tr>
</thead>
</table>
Run Code Online (Sandbox Code Playgroud)
我的json数据格式是
{"identifier":"idstudents","items":[{"idstudents":"11","first_name":"Pradip","middle_name":"Maan","last_name":"Chitrakar"}]}
Run Code Online (Sandbox Code Playgroud)
我该怎么做?请给我一些想法
我知道的一种方法是,在网格结构中定义该列的格式化方法.因此,不是以声明方式定义网格的结构,而是在JavaScript对象中定义,如下所示
var structure = [
{
name: "First Name",
field: "first_name"
},
{
name: "Action",
field: "_item",
formatter: function(item){
var btn = new dijit.form.Button({
label: "Edit"
});
return btn;
}
}
Run Code Online (Sandbox Code Playgroud)
]
并将此结构设置为网格
<table dojoType="dojox.grid.DataGrid" id="studentsGrid" data-dojo-id="studentsGrid" columnReordering="true" sortFields="['idstudents','first_name','middle_name','last_name']" store="studentsStore" clientSort="true" selectionMode="single" rowHeight="25" noDataMessage="<span class='dojoxGridNoData'>No students found</span>" structure=structure >
Run Code Online (Sandbox Code Playgroud)