vendredi 19 septembre 2014

How to know if there are any pending records to be updated in a store ?

Hello,

I have a grid Panel where I am displaying number of records. There are 2 button, 'Update' and 'Close'.

If we will click the 'close' button, then it should see if there are any pending record, if yes then it should tell the user to finish it,

if no then it will redirect to another URL.


In 'dockedItems' there is a close button. In there I have to write the logic. I know, I have to use isDirty() function, but I need guidance how to use that.


{

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

}],






How to know if there are any pending records to be updated in a store ?

Aucun commentaire:

Enregistrer un commentaire