Results 1 to 10 of 10

Thread: some data.Field are not posted when I modifie a record

  1. #1
    Sencha User
    Join Date
    Jul 2010
    Posts
    304
    Vote Rating
    0
      0  

    Default some data.Field are not posted when I modifie a record

    Hi,
    I have a Jsonstore with Ext.data.Field as following :

    Code:
                gridFields[j] = new Ext.data.Field({
                    name: field.fldId,
                    mapping: field.fldId,
                    atLeastOneYes: field.atLeastOneYes
    
                });
                j++;
                gridFields[j] = new Ext.data.Field({
                    name: field.fldId + '_STAT',
                    mapping: field.fldId + '_STAT',
                    defaultValue: '999'
    
    
                });
                j++;
                gridFields[j] = new Ext.data.Field({
                    name: field.fldId + '_FCB',
                    mapping: field.fldId + '_FCB',
                    defaultValue: ''
                });
                j++;
    and the jsonStore :
        var remoteGridJsonStore = new Ext.data.JsonStore({
            proxy: remoteGridProxy,
            baseParams: baseParams,
            storeId: 'remoteGridJsonStore_' + sptNbr + '_' + gridNbr,
            root: 'records',
            autoLoad: false,
            totalProperty: 'totalCount',
            remoteSort: false,
            fields: gridFields,
            idProperty: 'id',
            autoSave: false,
    Furthermore in some cases I create a record when the jsonStore is empty this way :

    Code:
                           var newRecord = new remoteGridJsonStore.recordType({
                                newRecordId : Ext.id()
                            });
                            newRecord.set('rowSeq', rowSeq);
                            newRecord.set('markToDelete', false);
                            newRecord.set('mark', false);
                            newRecord.set(........)
    
                            remoteGridJsonStore.add(newRecord);
    When I change the values of the record and I post the jsonStore some Ext.data.Field of my record are not posted. I checked that all the values are present in the record and the store but some are not posted

    I don't know how to solve this. Everything seems to be correct

    Thank you in advance for your answers

  2. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,385
    Vote Rating
    1540
      0  

    Default

    What do you mean post the JsonStore? You mean submit the modified records?

    If you are using a Writer on the Store, by default it will only submit the modified fields. To change this, on your Writer, set the config property writeAllFields to true.

    http://dev.sencha.com/deploy/dev/doc...ata.DataWriter
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Frontend Engineer
    ________________
    Need any sort of Ext JS help? Modus Create is here to help!

    Check out my GitHub:
    https://github.com/mitchellsimoens

  3. #3
    Sencha User
    Join Date
    Jul 2010
    Posts
    304
    Vote Rating
    0
      0  

    Default

    Hi mitchellsimoens and thank you for your answer,
    yes I mean submit the modified records

    actually I already use as you said a Writer with the writeAllFields property set to true. But some of my data.fields are not submitted

  4. #4
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,385
    Vote Rating
    1540
      0  

    Default

    And you have made sure that your records have the fields you want?

    It's kind of hard to visualize what you are doing as it seems you have copied and pasted some code together so it's messy code that you posted.
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Frontend Engineer
    ________________
    Need any sort of Ext JS help? Modus Create is here to help!

    Check out my GitHub:
    https://github.com/mitchellsimoens

  5. #5
    Sencha User
    Join Date
    Jul 2010
    Posts
    304
    Vote Rating
    0
      0  

    Default

    Sorry, here is the entire code :
    The Ext.data.Field
    Code:
        gridFields[0] = new Ext.data.Field({
            name: 'id',
            mapping: 'id'
        });
        gridFields[1] = new Ext.data.Field({
            name: 'rowSeq',
            mapping: 'rowSeq',
            type: 'int'
        });
        gridFields[2] = new Ext.data.Field({
            name: 'markToDelete',
            mapping: 'markToDelete',
            type: 'boolean'
        });
        gridFields[3] = new Ext.data.Field({
            name: 'mark',
            mapping: 'mark',
            type: 'boolean'
        });
        gridFields[4] = new Ext.data.Field({
            name: 'unmark',
            mapping: 'unmark',
            type: 'boolean'
        });
        var j = 5;
        for (var i = 0; i < pageGridFields.records.length; i++) {
            field = pageGridFields.records[i];
            if (field.fldType == "SLE"
                    || field.fldType == "MLE"
                    || field.fldType == "NUM"
                    || field.fldType == "DAT"
                    || field.fldType == "CBX"
                    || field.fldType == "SLB"
                    || field.fldType == "DLB") {
                gridFields[j] = new Ext.data.Field({
                    name: field.fldId,
                    mapping: field.fldId,
                    atLeastOneYes: field.atLeastOneYes
    
                });
                j++;
                gridFields[j] = new Ext.data.Field({
                    name: field.fldId + '_STAT',
                    mapping: field.fldId + '_STAT',
                    defaultValue: '999'
    
    
                });
                j++;
                gridFields[j] = new Ext.data.Field({
                    name: field.fldId + '_FCB',
                    mapping: field.fldId + '_FCB',
                    defaultValue: ''
                });
                j++;
            }
            }
    
    
        }
    The store with its proxy and writer :
    Code:
        var gridWriter = new Ext.data.JsonWriter({
            writeAllFields: true
        });
        var remoteGridProxy = new Ext.data.HttpProxy({
            api:{
                read: { url: '../secure/getSubjectDataGrid.htm', method: 'GET', timeout: 240000 },
                create: { url: '../secure/createSubjectDataGrid.htm', method: 'POST', timeout: 240000 },
                update: { url: '../secure/updateSubjectDataGrid.htm', method: 'POST', timeout: 240000 },
                destroy: { url: '../secure/deleteSubjectDataGrid.htm', method: 'POST', timeout: 240000 }
            }
        });
        var remoteGridJsonStore = new Ext.data.JsonStore({
            proxy: remoteGridProxy,
            baseParams: baseParams,
            storeId: 'remoteGridJsonStore_' + sptNbr + '_' + gridNbr,
            root: 'records',
            autoLoad: false,
            totalProperty: 'totalCount',
            remoteSort: false,
            fields: gridFields,
            idProperty: 'id',
            autoSave: false,
            successProperty: 'success',
            writer: gridWriter,
    .................................
    The creation of the new record which is not entirely submited :
    Code:
                            var newRecord = new remoteGridJsonStore.recordType({
                                newRecordId : Ext.id()
                            });
                            newRecord.set('rowSeq', rowSeq);
                            newRecord.set('markToDelete', false);
                            newRecord.set('mark', false);
                            remoteGridJsonStore.add(newRecord);
                            recordId = newRecord.id;
    
                            for (var k = 0; k < pageGridFields.records.length; k++) {
                                field = pageGridFields.records[k];
                                if (field.fldType == "CBX") {
                                    newRecord.set(field.fldId, false);
                                } else {
                                    newRecord.set(field.fldId, '');
                                }
                                newRecord.set(field.fldId + '_STAT', '999');
                                newRecord.set(field.fldId + '_FCB', '');
                                formFields[k] = buildField(field, recordId, rowSeq, remoteGridJsonStore, subjectId, frozen, screenSequence, id, sptNbr, gridNbr);
                                addDefaultValue(formFields[k]);
                                if (isEditField(field)) {
                                    newRecord.set(field.fldId, formFields[k].getValue());
                                }
                            }
    Actually some '_STAT' Ext.data.Field are not submitted

    I change the value of those '_STAT' Ext.data.Field in the change handler of Ext.form.Field

    Code:
                    listeners: {
                        change: function(field, newValue, oldValue) {
                            var record = field.jsonStore.getById(field.rowId);
                            record.set(field.fieldId, field.getRawValue());
                            var oldStatus = record.get(field.fieldId+'_STAT');
                            if (oldStatus == Status.NEVENT && newValue != '') {
                                record.set(field.fieldId+'_STAT', Status.NOTCLE_NEVMAR_COM);
                            }
                        },

  6. #6
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,385
    Vote Rating
    1540
      0  

    Default

    One thing I see is when you create a new record, you do this:

    Code:
    var newRecord = new remoteGridJsonStore.recordType({
    	newRecordId : Ext.id()
    });
    newRecord.set('rowSeq', rowSeq);
    newRecord.set('markToDelete', false);
    newRecord.set('mark', false);
    remoteGridJsonStore.add(newRecord);
    recordId = newRecord.id;
    According to the API docs, to create a new record, you should do this:

    Code:
    var id = Ext.id();
    var newRecord = new remoteGridJsonStore.recordType({
    	newRecordId : id,
    	rowSeq : rowSeq,
    	markToDelete : false,
    	mark : false
    }, id);
    remoteGridJsonStore.add(newRecord);
    recordId = id;
    First param should be a data object and the second should be an id (which is optional)
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Frontend Engineer
    ________________
    Need any sort of Ext JS help? Modus Create is here to help!

    Check out my GitHub:
    https://github.com/mitchellsimoens

  7. #7
    Sencha User
    Join Date
    Jul 2010
    Posts
    304
    Vote Rating
    0
      0  

    Default

    I also try to debug with ext-all-debug.js but I don't know where I can put a breakpoint to see which data.Fields are submited

  8. #8
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,385
    Vote Rating
    1540
      0  

    Default

    Quote Originally Posted by flamant View Post
    I also try to debug with ext-all-debug.js but I don't know where I can put a breakpoint to see which data.Fields are submited
    If you are using Firebug or WebKit Inspector, you can see the request and response.
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Frontend Engineer
    ________________
    Need any sort of Ext JS help? Modus Create is here to help!

    Check out my GitHub:
    https://github.com/mitchellsimoens

  9. #9
    Sencha User
    Join Date
    Jul 2010
    Posts
    304
    Vote Rating
    0
      0  

    Default

    Code:
    var id = Ext.id();
    var newRecord = new remoteGridJsonStore.recordType({
    	newRecordId : id,
    	rowSeq : rowSeq,
    	markToDelete : false,
    	mark : false
    }, id);
    remoteGridJsonStore.add(newRecord);
    recordId = id;
    I also already tried this former way but without success

  10. #10
    Sencha User
    Join Date
    Jul 2010
    Posts
    304
    Vote Rating
    0
      0  

    Default

    I finally solved the problem,
    In fact the fields in the record that were not sent had a "undefined" value and EXTJS doesn't send them

Similar Threads

  1. How to get a field value from Ext.Data.Record?
    By bryanevil in forum Ext 3.x: Help & Discussion
    Replies: 1
    Last Post: 26 Jun 2010, 2:08 AM
  2. Replies: 5
    Last Post: 24 Jan 2010, 10:06 PM
  3. add this field to what is posted with ajax
    By skidz in forum Ext 2.x: Help & Discussion
    Replies: 5
    Last Post: 2 May 2009, 3:57 AM
  4. Replies: 1
    Last Post: 12 Jun 2008, 9:11 PM
  5. How to map a complex json field into an Ext.data.record field?
    By Northdude in forum Ext 2.x: Help & Discussion
    Replies: 0
    Last Post: 7 Apr 2008, 11:27 AM

Posting Permissions

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