1. #1
    Sencha User
    Join Date
    Nov 2009
    Posts
    45
    Vote Rating
    1
    rex0098 is on a distinguished road

      0  

    Default help editor grid

    help editor grid


    hello every one i have a problem with my code....
    I'd like my editor grid to send back all data to my data base in a single row even if i only changed one of it's column...
    is that possible??? if so could anyone give me an example....
    I've searched the net for it but i havent found that could help me...the code i have now does work but it only passes the data from the column that was changed....

  2. #2
    Sencha Premium Member
    Join Date
    Feb 2009
    Location
    Glasgow, Scotland
    Posts
    334
    Vote Rating
    12
    Stuart-SwarmOnline will become famous soon enough Stuart-SwarmOnline will become famous soon enough

      0  

    Default


    Is this what you mean?

    Config option of JsonReader:

    writeAllFields : Booleanfalse by default. Set true to have DataWriter return ALL fields of a modified record -- not just those that changed....
    false by default. Set true to have DataWriter return ALL fields of a modified record -- not just those that changed. false to have DataWriter only request modified fields from a record.

  3. #3
    Sencha User
    Join Date
    Nov 2009
    Posts
    45
    Vote Rating
    1
    rex0098 is on a distinguished road

      0  

    Default thank you...

    thank you...


    thank you for the info i got caught up on the grid that i forgot about the config option of jsonwriter silly me lol.....^_^

    but i have another question how can i make 2 column of in a row change data simultaneously??
    see pic:

    Untitled-1.jpg

    first column is the account description and the second is the account code...what i want to do is when i pick a description the account code would also change to its corresponding code. I've got a working code but i just cant figure out how to do it inside the grid...
    [IMG]file:///C:/DOCUME%7E1/rodel/LOCALS%7E1/Temp/moz-screenshot.png[/IMG]

  4. #4
    Sencha Premium Member
    Join Date
    Feb 2009
    Location
    Glasgow, Scotland
    Posts
    334
    Vote Rating
    12
    Stuart-SwarmOnline will become famous soon enough Stuart-SwarmOnline will become famous soon enough

      0  

    Default


    Listen for the afteredit event on the grid and do some checks for the field being edited and if it's the description one then update the code one.

    Code:
    this.on('afteredit', function(e){
    
         if(e.field === 'Description'){
    
               var code = this.getCodeFromDescription(e.value); // get the equivalent code from somewhere, the Combo's store maybe?
               e.record.Code = code;
         }
    
    }, this);
    
    // untested!

  5. #5
    Sencha User
    Join Date
    Nov 2009
    Posts
    45
    Vote Rating
    1
    rex0098 is on a distinguished road

      0  

    Default


    the afteredit event was really helpful thank you...but i can't seem too figure out how to change the account code
    this is my afteredit function:
    Code:
    afteredit: function(e)
     {
         if(e.field == 'CD_account_description' && e.value == 'Accounts Payable')
        {
    
             //this is the part where i get lost ^_^
            var x = e.record.data.CD_account_code;
               // x is the original value of the account code 
        }
     }
    after i change the account description field value to 'Accounts Payable' how can i change the value of x to match my account description to its account code...please give me some more example if you have thank you....

  6. #6
    Sencha Premium Member
    Join Date
    Feb 2009
    Location
    Glasgow, Scotland
    Posts
    334
    Vote Rating
    12
    Stuart-SwarmOnline will become famous soon enough Stuart-SwarmOnline will become famous soon enough

      0  

    Default


    Where are you storing the equivalent Account Codes? The simplest (and nastiest...) answer is to do a massive switch or if/else if statement to pick out the right Account Code. However, probably the best way would be to store the AccountCode in the Account Description's combo store and then get it from that.

    Code:
    afteredit: function(e)
     {
         if(e.field == 'CD_account_description' && e.value == 'Accounts Payable')
        {
    
             var editor = e.grid.getColumnModel().getCellEditor(e.Column, e.Row);
    
             // get the index of the selected description record
             var selectedDescriptionIndex = editor.getStore().findExact('Description', e.value);
    
             // get the description record
             var selectedDescription = editor.getStore().getAt(selectedDescriptionIndex);
    
             // assign the Description's accountCode to the grid's record
             record.data.AccountCode = selectedDescription.data.AccountCode;
    
    }
    }
    
    //again, untested and a little bit theoretical!
    Last edited by Stuart-SwarmOnline; 27 Sep 2010 at 1:10 AM. Reason: weird formatting....

  7. #7
    Sencha User
    Join Date
    Nov 2009
    Posts
    45
    Vote Rating
    1
    rex0098 is on a distinguished road

      0  

    Default


    again thank you for the quick reply..sadly i used the nastiest way to do it..^_^
    but that's ok because i'm not working with that many account codes to begin with so that's fine with me and
    my account code fiels is not a combobox either its just a plain numberfield..^_^
    it's working just fine now...thank you for all your help.....but i have another question..

    Untitled-1.jpg

    i have an amount column and i want to show their sum at the bottom of the grid or after the last amount is it possible??and i was also thinking of putting in at the bottom bar..please give me your opinion...thank you again

  8. #8
    Sencha Premium Member
    Join Date
    Feb 2009
    Location
    Glasgow, Scotland
    Posts
    334
    Vote Rating
    12
    Stuart-SwarmOnline will become famous soon enough Stuart-SwarmOnline will become famous soon enough

      0  

    Default


    Check out the Grid Summary Plugin (http://www.sencha.com/forum/showthre...221#post111221) (latest code is always on Post#9)

    It's really good and easy to implement.

  9. #9
    Sencha User
    Join Date
    Nov 2009
    Posts
    45
    Vote Rating
    1
    rex0098 is on a distinguished road

      0  

    Default


    hello again mr.stoot98 i have not yet got the hang of using the plugin you
    referred but its ok i'll figure it out soon..

    i have a question about the the grid you've helped me with...when i select an account description the account code changes as well but their cell does not become dirty so when i click on the save button and my grid reloads it still have the same value not the once i selected. here is the code that i used:

    Code:
    if(e.field == 'CD_account_description' && e.value == 'Owner Capital')
      {
          var x = e.record.data.CD_account_code = 301;
           e.record.commit();
      }
    i used the commit function to change the account code value when i select an account description but i think it only changes the value in the cell but not on the store.is there any other function function i can use? thank you again.... ^_^

  10. #10
    Sencha Premium Member
    Join Date
    Feb 2009
    Location
    Glasgow, Scotland
    Posts
    334
    Vote Rating
    12
    Stuart-SwarmOnline will become famous soon enough Stuart-SwarmOnline will become famous soon enough

      0  

    Default


    By calling e.record.commit() you are marking the record as 'clean' (i.e. not dirty) and so it won't be included in the next Store save.

Similar Threads

  1. proble in tab key in editor grid with singel editor columnpleace
    By auminfosys in forum Ext 2.x: Help & Discussion
    Replies: 0
    Last Post: 14 May 2010, 11:08 PM
  2. Replies: 1
    Last Post: 17 Apr 2009, 5:49 AM
  3. Replies: 1
    Last Post: 17 Apr 2009, 5:49 AM
  4. Adding ContextMenu to the TextArea Editor field of an Editor Grid Panel
    By fakoua in forum Ext 2.x: Help & Discussion
    Replies: 0
    Last Post: 11 Sep 2008, 7:06 AM

Thread Participants: 1