View Full Version : create new user in grid
elnaz
12 Aug 2011, 12:07 AM
create new user in grid MVC
I want to create new user for gridlist ..
I create a separate panel and link the button to open it and it's work
now ,I want to save this new user to main list ,
I don't know how should I save it.
and also when I create new panel (form ) for creating new user should I
create new model also or should I use the model that i have for main list?
elnaz
12 Aug 2011, 5:22 AM
is any one knows about creating new user in grid list ?
slemmon
12 Aug 2011, 5:26 AM
Your grid and form should be able to use the same model.
To add a user to your grid you will use the grid's store's insert method.
http://docs.sencha.com/ext-js/4-0/#/api/Ext.data.Store-method-insert
You might look at the code for this example. I found it very helpful myself.
http://dev.sencha.com/deploy/ext-4.0.2a/examples/writer/writer.html
elnaz
12 Aug 2011, 5:38 AM
thanks for Reply
In this example they using
this.editing = Ext.create('Ext.grid.plugin.CellEditing');but what should I do when I didn't use this plug in?
var rec = new Writer.Person({ first: '', last: '', email: '' }), edit = this.editing; edit.cancelEdit(); this.store.insert(0, rec); edit.startEditByPosition({ row: 0, column: 1 });
slemmon
12 Aug 2011, 5:50 AM
Yeah, they're doing in this example quite a bit of stuff. You wouldn't use the editor parts. In this example they make a 'create' event and when you click the create button it fires the create event. There is then a listener for create that responds and does the 'insert' into the grid's store. You can cut those interactions out and basically just put a handler on a button on your form that gets the grid and then its store and does an insert using the form's fields. In the example code you'll see where it does a form.getValues() and then uses that result in the store.insert(0 , form_values_as_record_here).
Powered by vBulletin® Version 4.1.5 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.