Results 1 to 3 of 3

Thread: Destroy in HttpProxy not firing when remove record from store

  1. #1
    Ext JS Premium Member
    Join Date
    Feb 2010
    Location
    DC Metro Area
    Posts
    4

    Default Destroy in HttpProxy not firing when remove record from store

    Hello,

    I'm having a problem with updating the HttpProxy and the GridPanel. When I remove a record from the grid by using the remove method on the store, the HttpProxy is not hitting the web service at all. I'm using Fiddler to check the communication between the page and the webservice, and there is no communication whatsoever. If I use Ext.Ajax.request explicitly, it works fine and I can see the request and the response. The odd thing is that read works fine and if I drag/drop a record within the grid, create works as well.

    I'm not sure what I am doing wrong. My code is included below.

    Thanks in advance,
    Robert

    Code:
    var writer = new Ext.data.JsonWriter({
            encode: false,
            writeAllFields: true
        });
    
        var myProxy = new Ext.data.HttpProxy({
            headers: { 'Content-Type': 'application/json; charset=utf-8;' },
            jsonData: { contractPrId: $('#contractPrId').val(),
                exhibitId: $('#exhibitId').val(),
                cdrlId: $('#dataItemId').val()
            },
            method: 'POST',
            api: {
                read: { url: 'components/services/ExtJsDdpGridService.asmx/GetDataDistributionProfile' },
                destroy: { url: 'components/services/ExtJsDdpGridService.asmx/DeleteDdpListEntry' },
                create: { url: 'components/services/ExtJsDdpGridService.asmx/addDdpListEntry' },
                update: { url: 'components/services/ExtJsDdpGridService.asmx/updateDdpListEntry' }
            }
        });
    
    Ext.data.JsonReader.override({
            read: function(response) {
    
                var json = response.responseText;
                var o = Ext.util.JSON.decode(json);
    
                if (o.d)
                    o = o.d;
    
                o = JSON.parse(o);
    
                if (!o) {
                    throw {
                        message: "JsonReader.read: Json object not found"
                    };
                }
    
                return this.readRecords(o);
            }
        });
    
        var store = new Ext.data.JsonStore({
            id: "jsonStoreId",
            root: 'ddpListEntries',
            totalProperty: 'totalCount',
            fields: ['ddpListEntryId', 'cdrlId', 'codeRepresentativeId', 'codeRepName', 'code', 'draft', 'required', 'remarks', 'sortOrder', 'organization'],
            proxy: myProxy,
            writer: writer,
            autoSave: true,
            autoDestroy: true
        });
    
        store.load();
    
        var ddpGrid = new Ext.grid.GridPanel({
            width: 200,
            title: 'Profile',
            store: store,
            region: 'center',
            trackMouseOver: false,
            enableDragDrop: true,
            ddGroup: 'depGridDD',
            loadMask: true,
            margins: '3 3 3 3',
            tbar: [{
                text: 'Delete',
                iconCls: 'silk-delete',
                scope: this,
                handler: function(button, event) {
                    var rec = ddpGrid.getSelectionModel().getSelected();
                    rec.markDirty();
                    if (!rec) {
                        return false;
                    }
    
                    ddpGrid.store.remove(rec);
                }
    }],
                sm: new Ext.grid.RowSelectionModel({ singleSelect: true }),
    
                // grid columns
                columns: [
                {
                    header: 'Organization',
                    dataIndex: 'organization',
                    hidden: false,
                    width: 25,
                    sortable: false
                },
                {
                    header: "Code",
                    dataIndex: 'code',
                    width: 25,
                    sortable: false
                }, {
                    header: "Code Rep Name",
                    dataIndex: 'codeRepName',
                    width: 50,
                    hidden: false,
                    sortable: false
                }, {
                    header: "Draft",
                    dataIndex: 'draft',
                    width: 15,
                    align: 'center',
                    sortable: false
                }, {
                    header: "Required",
                    dataIndex: 'required',
                    width: 15,
                    sortable: false
    }],
    
                    // customize view config
                    viewConfig: {
                        forceFit: true
                    }
                });

  2. #2

    Default

    The Jsonstore's id = "jsonStoreId", but in fields this field does not exists.

    Thats makes all records panthom property = true(means the record does not exits in server), so, the store does not launch the delete proxy call.

  3. #3
    Ext JS Premium Member
    Join Date
    Feb 2010
    Location
    DC Metro Area
    Posts
    4

    Default

    Quote Originally Posted by kikearake View Post
    The Jsonstore's id = "jsonStoreId", but in fields this field does not exists.

    Thats makes all records panthom property = true(means the record does not exits in server), so, the store does not launch the delete proxy call.
    I was going through my email and saw that you had responded to my initial query and wanted to thank you. I eventually made the same determination after stepping through the code with my debugger. It did take a bit of work, though. :-) However, once I made the appropriate changes, it began to work as it should.

    Thanks again,
    Robert Eberhart

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •