View Full Version : create new user in grid

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?

12 Aug 2011, 5:22 AM
is any one knows about creating new user in grid list ?

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.

You might look at the code for this example. I found it very helpful myself.

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 });

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).