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.
You made several errors in your getDelete function:
I think this will work for you:
function getDelete(item) {
return "<button onclick=\"location.href='/report?command=delete&reportNo="
+ item + "'\">Delete</button>";
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With