0

I need to add a 'Save' button to my Editor grid panel. Everything I have tried does not work. Thanks for your help. Here is my code.

var iLineItemGrid = new Ext.grid.EditorGridPanel({
    id: 'iLineItemStore',
    store: iLineItemStore,
    cm: iLineItemCM,
    cls: 'iLineItemGrid',
    width: 'auto',
    height: 'auto',
    frame: true,
    //title:'Edit Plants?',
    //plugins:checkColumn,
    clicksToEdit:1,
    viewConfig: {
        //forceFit: true
        autoFit:true
    },        
    tbar:  [{
        text: 'Add',
        tooltip:'Add the line item',
        handler : function(){
            var r = new iLineItemRec({
                i_line_item_name: '',
                i_line_item_amt: ''
            });
            iLineItemGrid.stopEditing();
            iLineItemStore.insert(0, r);
            iLineItemGrid.startEditing(0, 0);
        },
        //Should this be scope:this or scope:iLineItemGrid?
        scope:iLineItemGrid
    }, {
        text: 'Delete',
        tooltip:'Remove the selected line item',
        handler: function(){
            iLineItemGrid.stopEditing();
            var r = iLineItemGrid.getSelectionModel().getSelectedCell();
            iLineItemStore.removeAt(r[1]);
        },
        //Should this be scope:this or scope:iLineItemGrid?
        scope:iLineItemGrid
    }],
    //MIKE SAVE BUTTON
    buttons: [{
        text: 'Save',
        tooltip: 'Click to save all changes to the database',
        handler: function() {
            iLineItemStore.each(function(record) {
                Ext.Ajax.request({
                    url: 'UpdateInvoiceDataAction.do',
                    //ADD AN ALERT TEXT HERE TO TEST IT
                    success: function() {
                        iLineItemGrid = false;
                        Ext.MessageBox.hide();
                        Ext.MessageBox.alert('Success', 'This record has been saved');
                    },
                    failure: function() {
                        iLineItemGrid.isLoaded = false;
                        cmh.display(action.result);
                    },
                    callback: function(records, options, success) {
                        //SOMEWHERE IN HERE POPULATE THE 'AMOUNT DUE' textfield
                        //How do I set this value?
                        Ext.getCmp('iAmountDue').setValue(Toa.Application.invId)
                    },
                    params: record.data
                });
            }
            )
        },
        //Should this be scope:this or scope:iLineItemGrid?
        scope:iLineItemGrid
    }]            
});
2
  • What exactly isn't working? Does the button fail to get added to your panel, or does the button you've added simply not work as intended? Please add more detail about your expected behaviour so we can better assist. Jul 31, 2012 at 12:57
  • Hello Daniel, The button does not work as intended. I was thinking that I should make the save button apart of the tbar instead.
    – michael
    Jul 31, 2012 at 14:57

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.