I am trying to add a delete button to the Dojo Datagrid and I currently have the following javascript:
function createGrid() {
gridTmp = new dojox.grid.DataGrid({
store: jsonStore,
structure: [
{name: "Report No", field:"inc_number"},
{name: "Incident Date", field: "IncidentDate"},
{name: "Report Date", field: "reportDate"},
{name: "Location", field: "location"},
{name: "Delete", field: "inc_number", formatter: getDelete}
],
noDataMessage: 'No results returned'
}, "grids");
return gridTmp;
}
dojo.addOnLoad(function() {
grid = createGrid();
grid.startup();
});
function getDelete(item) {
return "<button onclick=\"location.href='/report?command=delete&reportNo=" + store.getIdentity(item) + "'\">Delete</button>";
}
Whenever I load the page I only get an empty grid with a message "sorry an error occurred." If I remove the last field with the "getDelete" formatter, the datagrid populates just fine. I am not sure what I am doing wrong so any help would be appreciated.