Results 1 to 9 of 9

Thread: Critical Field will not be sent on store remove action

    You found a bug! We've classified it as EXTJS-14725 . We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.
  1. #1
    Sencha User
    Join Date
    May 2014
    Posts
    7
    Vote Rating
    3
      1  

    Default Critical Field will not be sent on store remove action

    Hello community,

    I have a proxy store which is connected to my php backend (mysql). Everything is working fine but there is one problem. When I want to sync the remove action the critical field (FieldID) will no be sent to the server. In every other action this field will be sent how it is described in the api. Is this a bug or is there any other way to solve this problem. The only thing i don't want to do is to send every field to server.

    Store:
    Code:
    Ext.define('EDC.store.FieldsByTableID', {
        extend: Ext.data.Store,
        requires: 'EDC.model.Field',
        model: 'EDC.model.Field',
        autoSync: true,
        proxy: {
            type: 'ajax',
            api:{
                read: 'data/get/FieldsByTableID',
                create: 'data/insert/Field',
                update: 'data/update/Field',
                destroy: 'data/delete/Field'
            },
            actionMethods: {
                read: 'POST'
            },
            reader: {
                type: 'json'
            },
            writer: {
                type: 'json',
                rootProperty: 'data',
                writeAllFields: false,
                writeRecordId: true,
                allowSingle: false
            }
        },
        listeners: {
            write: function(store, operation, eOpts){
                Ext.example.msg("Server Info",operation._resultSet.message);
            }
        }
    });
    Model:
    Code:
    Ext.define('EDC.model.Field', {
        extend: 'Ext.data.Model',
        idProperty: 'id',
        fields: [
        {
            name: 'FieldID',
            type: 'int',
            critical: true
        }, 
        'Description', 'Name',
        'Key', 'DataType', 'Convention',
        'Notes', 'CreatedBy', 'ModifiedBy', 
        'Type', 'created_at', 'updated_at', 
        'TableID']
    });

  2. #2
    Sencha User
    Join Date
    Oct 2010
    Posts
    45
    Vote Rating
    5
      0  

    Default

    Inside your store's proxy:
    writer: {
    writeAllFields: true
    }

    That's probably what you will have no choice but to do. But is it really that big a deal to do that? So what if you have to send them all, but it works, no?

  3. #3
    Sencha User slemmon's Avatar
    Join Date
    Mar 2009
    Location
    Boise, ID
    Posts
    6,165
    Vote Rating
    255
      0  

    Default

    Out curiosity, you have idProperty as 'id', but I don't seen an 'id' field in the fields array. If you set 'FieldId' as the idProperty does that solve the issue when writing back to the server?

  4. #4
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,791
    Vote Rating
    392
      0  

    Default

    At first glance this appears to be a bug:

    http://docs.sencha.com/extjs/5.0.0/a...-getRecordData

    Destroy operations don't seem to take critical fields into account, which doesn't feel right to me.

  5. #5
    Sencha Premium Member
    Join Date
    May 2010
    Location
    Guatemala, Central America
    Posts
    1,557
    Vote Rating
    379
      0  

    Default

    Quote Originally Posted by skirtle View Post
    At first glance this appears to be a bug:

    http://docs.sencha.com/extjs/5.0.0/a...-getRecordData

    Destroy operations don't seem to take critical fields into account, which doesn't feel right to me.
    Is the version field sent?

    Conceptually for deletion you only need the entity id and to be sure that nobody changed it before deletion the version. IMHO other fields shouldn't be needed for deletion.

    Regards.
    UI: Sencha Architect / ExtJS 4 - 6
    Server side: JEE / EJB 3.x / CDI / JPA 2.x/ JAX-RS / JasperReports
    Application Server: WildFly / Weblogic
    Databases: Oracle
    / MySQL / DB2 / Firebird

    If you like my answer please vote!

  6. #6
    Sencha User slemmon's Avatar
    Join Date
    Mar 2009
    Location
    Boise, ID
    Posts
    6,165
    Vote Rating
    255
      0  

    Default

    Thanks for the report! I have opened a bug in our bug tracker. I believe the thinking currently is that you'd only send the id up on delete actions, but we'll continue to review this internally. Thanks again for the feedback.

  7. #7
    Sencha User
    Join Date
    Sep 2014
    Posts
    39
    Vote Rating
    7
      0  

    Default

    Here is my workaround.

    Code:
    Ext.define('MyApp.util.MyWriter', {
        extend: 'Ext.data.writer.Json',
        getRecordData:function(record, operation){
            if (operation.action === 'destroy') {
                var returnItem = {};
                var items = record.getCriticalFields();
    
    
                for(var i = 0; i < items.length; i++) {
                    returnItem[items[i].getName()] = record.data[items[i].getName()]
                }
    
    
                return returnItem;
            } 
            
            return Ext.create('Ext.data.writer.Json').getRecordData(record, operation);
        }
    })
    Extend the json writer in my case. If the action is a delete, I am sending the critical fields back, otherwise I am calling the normal function to run.

    Implementation of the new writer:
    Code:
    writer: Ext.create('MyApp.util.MyWriter')
    The writer is in the Proxy defined in my store.

    Just a simple way to send critical fields in a delete request. This prevents you from having to 1) send all fields, or 2) define another key field. You can also mark as many fields as you need as critical, and all of them will go.

  8. #8
    Sencha Premium Member
    Join Date
    Oct 2014
    Posts
    5
    Vote Rating
    0
      0  

    Default

    Just a note here: not sure if all servers support reading of request body on delete operation. It might be more universal to use URL query string as transport for critical fields.

  9. #9
    Sencha User
    Join Date
    Sep 2011
    Posts
    17
    Vote Rating
    3
      0  

    Default

    still happening in Ext 6.5.2. years without a fix have passed.

Tags for this Thread

Posting Permissions

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