У меня есть панель сетки, где я показываю количество записей. Есть 2 кнопки, 'Update
' и 'Close
'. Если мы нажмем кнопку «close
», то он должен увидеть, есть ли какие-либо ожидающие записи, если да, то он должен сказать пользователю завершить ее, если нет, то он перенаправит на другой URL-адрес.
В 'dockedItems
' есть кнопка закрытия. Там я должен написать логику. Я знаю, что мне нужно использовать функцию isDirty()
, но мне нужно руководство, как ее использовать.
{
xtype : 'gridpanel',
region: 'center',
title : 'Search Results',
id : 'searchResultsGrid',
plugins: [{
ptype: 'cellediting',
listeners: {
beforeedit : function (editor, context, eOpts) {
console.log('beforeedit');
},
edit : function (editor, context, eOpts) {
console.log('edit');
},
canceledit : function (editor, context, eOpts) {
console.log('canceledit');
}
}
}],
columnLines : true,
autoScroll : true,
selModel : new Ext.selection.CheckboxModel({
checkOnly: true,
enableKeyNav: false,
allowDeselect: true,
deselectOnContainerClick: false
}),
border : true,
resizable : true,
columns : gridColumnList,
store : {
model : poModel,
proxy : new Ext.Hmhco.SFDCProxy({
sessionId: '{!$Api.Session_ID}',
model: poModel,
url: "https://" + location.hostname + "/services/data/v31.0/"
})
},
dockedItems: [{
xtype: 'toolbar',
items: [{
itemId: 'update',
text: 'Update',
handler: function(button, evt) {
var grid = Ext.getCmp('searchResultsGrid'),
ds = grid.getStore();
ds.sync({
success : function (batch, options) {
console.log('Sync Success!');
},
failure : function (batch, options) {
var errorList = [],
exceptionList = batch.getExceptions();
for (var i = 0; i < exceptionList.length; i++) {
var err = exceptionList[i].getError();
errorList.push({
url: err.request.getUrl()
});
}
exceptionList = 1;
console.dir(errorList);
}
});
}
},'-', {
itemId: 'close',
text: 'Close',
handler: function(button, evt) {
// TO DO : It should see if there are pending updates (store.isDirty()) and confirm the close with the user via an Ext.Msg method.
}
}]
}], // dockedItems
}],