-
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....
-
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.
-
1 Attachment(s)
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:
Attachment 22558
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]
-
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!
-
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....
-
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!
-
1 Attachment(s)
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..
Attachment 22572
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
-
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.
-
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.... ^_^
-
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.