我正在使用 Dojo Toolkit 1.9 Datagrid,并且正在从 xmlStore 填充数据,但我面临一个问题,即在从数据网格中删除任何项目后,在我们手动刷新浏览器之前它不会刷新。请问有人可以建议我怎么做吗?源代码如下:
<html>
<head>
<title>User Demo</title>
<link rel="stylesheet" href="../dojo-release-1.9.1/dijit/themes/claro/claro.css">
<link rel="stylesheet" href="../dojo-release-1.9.1/dojox/grid/resources/claroGrid.css">
<script src='../dojo-release-1.9.1/dojo/dojo.js'></script>
<script src='myscript.js'></script>
<body>
<div id="ObjectGrid"></div>
</body>
</html>
var globalUserId;
var appContext = "/" + (window.location.pathname).split("/")[1];
require(
[ 'dojo/dom', 'dojo/json', 'dojox/json/schema',
'dojox/data/JsonRestStore', 'dojox/grid/DataGrid',
'dojox/grid/_CheckBoxSelector', 'dojo/on',
'dojo/request/xhr', 'dijit/Dialog', 'dojox/data/XmlStore',
'dijit/form/FilteringSelect', 'dijit/Calendar',
'dijit/form/Form', 'dijit/form/ValidationTextBox',
'dijit/form/TextBox', 'dijit/form/FilteringSelect',
'dijit/form/Button', 'dijit/layout/TabContainer',
'dijit/layout/ContentPane', 'dojo/domReady!' ],
function(dom, JSON, schema, JsonRestStore, DataGrid,
_CheckBoxSelector, on, xhr) {
var userDataStore12 = new dojox.data.XmlStore({
url : appContext + "/rest/userservice/getusers",
rootItem : "user"
});
var gridCell = [{field : "userid",name : "User Id",width : '10%'},
{field : "name",name : "Name",width : '15%'},
{field : "email",name : "Email",width : '15%'},
{field : "userName",name : "User Name",width : '10%'},
{field : "phone",name : "Phone",width : '10%'},
{field : "roleName",name : "Role",width : '10%'},
{field : "status",name : "Status",width : '10%'},
{name : "Action",field : "action",width : '10%',
formatter : function(item) {
var link = '<a href="#" title="Edit" onClick="updateUserDialog.show()"><div class="dijitIconEdit"></div></a> <a href="#" id="deleteUser" onClick="deleteUser();" title="Delete"><div class="dijitIconDelete"></div></a>';
return link;
}
}];
gridLayout = [ {
// First, our view using the _CheckBoxSelector custom type
type : "dojox.grid._CheckBoxSelector"
}, gridCell ];
grid = new DataGrid({
store : userDataStore12,
structure : gridLayout,
selectionMode : "single",
autoHeight : true
}, "ObjectGrid");
grid.startup();
on(grid, "RowClick", function showDetail(e) {
var gridUserId = grid.store.getValue(grid.getItem(e.rowIndex), "userid");
globalUserId = gridUserId;
});
});
function deleteUser() {
require([ 'dojo/dom', 'dojo/request' ], function(dom, request) {
//request for delete user
request.post(appContext + "/rest/userservice/deleteUser", {
data : "userId=" + globalUserId,
timeout : 2000
}).then(function(response) {
console.log("request sent successfully!!!!!!!");
});
});
}