-
23 Nov 2011 5:25 PM #11
"If so then there's really no need to do it in app.js ? Its just writing extra code for no reason."
You said declaring the "models array" doesn't work in app.js, so yes it would be useless code.
You said it does work when you declare the "models array" in the controller so that should be sufficient; even if it did work in app.js because as you say it would become extra code for no reason.
The MVC Architecture documentation itself shows that approach.Yes I am aware that the Viewport should be created as a view rather than explicitly created in the Launch function of app.js. It seems easier to have the application's "main" panel be created in app.js, and then add the other views from there.
According to the API the viewport is "a specialized container representing the viewable application area (the browser viewport)." And since there can only be 1 viewport per page, I assume it is declared in the launch() function. (as done by some of the Extjs examples) And since the layout (border, fit etc) is declared inside the Ext.create of the viewport, I believe you can't move it out of the Launch() function ?
-
23 Nov 2011 5:27 PM #12
-
24 Nov 2011 1:11 AM #13
Spent some time refactoring my code. It seems "proper" now. Also customized the viewport and added "reset" and "refresh" button functionalities. Note that the Navigation panel and Test Form is for cosmetic purposes.
Oh and i apologize about the innaccuracy of my previous post... i declared the controllers, models and stores array in app.js and it didn't throw errors now. Strange...
-
24 Nov 2011 2:05 PM #14
I think that is because you have made a version 3 app rather than a version 4 MVC app.
I say this because in app.js you wrap everything in an "Ext.onReady" which is a version 3 approach.
If you remove it and wrap everything in the "Ext.application" which is the version 4 approach then your problems reappear and we are back to the comment in my original post that "direct does not play nicely with version 4 MVC" and that is why we have to struggle so hard with the store.
.
-
5 Dec 2011 8:53 PM #15
@danielleng
Hello
I am trying to implement something similar with JAVA backend.
What backend have you used?If possible please upload the code,for reference.
The problem I am facing is listed below.
I get the right json format from database using java.
Its like this.
I have my script in an Html file.Code:{"device":[{"id":1,"uname":"Sachin","fname":"Sachin","lname":"Taware","emailid":"sachi@gmail.com","statename":"MH","cityname":"Pune","countryname":"India"},{"id":2,"uname":"Rahul","fname":"Rahul","lname":"Dravid","emailid":"rdravid@gmail.com","statename":"KA","cityname":"Bangalore","countryname":"India"},{"id":3,"uname":"MS","fname":"MS","lname":"Dhoni","emailid":"ms@gmail.com","statename":"JH","cityname":"Ranchi","countryname":"India"},{"id":4,"uname":"viru","fname":"Virender","lname":"Sehwag","emailid":"viru123@gmail.com","statename":"DL","cityname":"Delhi","countryname":"India"}]
But,now how can I pass it to the store?
The problem I think is in the proxy and reader section(I have highlighted it).Can I pass the URL of the class file of the compiled servlet ??If not any how to pass the json to the store?
Firebug still shows me the same error of invalid json.
Code:<script type="text/javascript"> Ext.onReady(function() { Ext.define('Company', { extend: 'Ext.data.Model', fields: [ {name:'uname',type: 'string'}, {name:'fname',type: 'string'}, {name:'lname',type: 'string'}, {name:'emailid',type: 'string'}, {name:'statename',type: 'string'}, {name:'cityname',type: 'string'}, {name:'country',type: 'string'}] }); var store_company = new Ext.data.Store({ model: 'Company', proxy: { type: 'ajax', url: 'register.class', reader: { type: 'json', root:'device' }, } }); var grid_company = Ext.create('Ext.grid.Panel', { store: store_company, columns:[ { text : 'User Name', width : 120, sortable : true, dataIndex: 'uname' }, { text : 'Firstname', width : 120, sortable : true, dataIndex: 'fname' }, { text : 'Lastname', width : 110, sortable : true, dataIndex: 'lname' }, { text : 'Email', width : 150, sortable : true, dataIndex: 'emailid' }, { text : 'State', width : 100, sortable : true, dataIndex: 'statename' }, { text : 'City', width : 150, sortable : true, dataIndex: 'cityname' }, { text : 'Country', width : 150, sortable : true, dataIndex: 'countryname' } ], bbar: Ext.create('Ext.PagingToolbar', { store: store_company, displayInfo: true, displayMsg: 'Displaying topics {0} - {1} of {2}', emptyMsg: "No topics to display" }), height: 210, width: 902, title: 'Company List', renderTo: 'grid-company', viewConfig: { stripeRows: true } }); store_company.load(); }); </script>
Regrds
Sachin
-
6 Dec 2011 10:00 AM #16
My original post was only to provide an updated version of existing code given in the documentation.
I am only a beginner and I do not have the knowledge you seek.
I can only point you to:
http://docs.sencha.com/ext-js/4-0/#!/guide/data
http://docs.sencha.com/ext-js/4-0/#!/guide/application_architecture
There is also the sample code in the download of the framework.
Hope this helps.
-
6 Dec 2011 11:42 AM #17
@rakagod
Thank you for the references.Will go through them.
I found the solution at http://www.sencha.com/forum/showthre...nd-Mysql/page2
Regards
Sachin
-
19 Jun 2012 1:45 PM #18
The update functionality doesn't work? Add neither, given it uses the update functionality...
Error message "Cannot call method save of undefind"
Any ideas why?
-
19 Jun 2012 2:17 PM #19
well it looks like
works fine for me though u had it commented out and replaced withCode:e.record.save()
which gives me the error...Code:editor.record.save()



Reply With Quote