You need to sign in to do that
Don't have an account?
Xisco
Fill in data in ExtJs Panel Grid
Hi,
I'm new in the plataform - I having some problems to fill in data in a ExtJs Panel Grid - When I got back the String in JSON format I define my Ext.Data.Model - I have some lookup up relations in my Query and I don't know how to define them in my Ext.Data.Model, the fields that don't have look up relationships work fine but I cant get the value from the ones that have it
If somebody can help me with this issue will be great!
Many thanks
Xisco :)
Here is my code:
<script type="text/javascript"> Ext.ns("Ext.Classing"); //Defining a namespace is best practice in ExtJS Ext.onReady(function(){ //This is a execution point //This is to create InCourse panel var InCoursePanel = new Ext.create('Ext.Classing.InCoursePanel', { renderTo: InCourse, title : 'Students to place' }); //This method is used to call our controller method Controller_ClassingSimpleGrid.getAllBookings(function(result, er){ var res = Ext.decode(result); store.loadData(res.Records); }, {escape:false}); }); //Defining a model, which is like an object Ext.define('ClassingStudentsModel', { extend : 'Ext.data.Model', fields :[ {name: 'Id', type: 'string'}, {name: 'Name', type: 'string'}, {name: 'Gender__c', type: 'string'}, {name: 'Nationality__c', type: 'string'} ] }); //Create a store, which is like collection of records with sorting and grouping capability var store = Ext.create('Ext.data.Store', { model : 'ClassingStudentsModel', //Associate your store with Model proxy : { type : 'memory', reader : { type : 'json', } } }); //Defining a panel in order to display our data Ext.define('Ext.Classing.InCoursePanel', { extend : 'Ext.grid.Panel', alias : 'widget.InCoursePanel', name : 'InCoursePanel', columnLines : true, autoScroll : true, singleSelect: false, border : true, height : 300, width : 250, store : store, //Associate with our store stripeRows : true, multiSelect : true, columns : [ //Define the required columns { text : 'Id', dataIndex : 'Id', flex : 0.3 //hidden : true, //hideable : false }, { text : 'Name', dataIndex : 'Name', flex : 0.3 }, { text : 'Gender', dataIndex : 'Gender__c', flex : 0.3 }, { text : 'Nationality', dataIndex : 'Nationality__c', flex : 0.3 } ], });
global class Controller_SimpleGrid { @RemoteAction global static String getAllBookings() //Need to define as a remote action as we will be calling this through javascript { List<Booking__c> bookings = [Select Id, Enrolment__r.Account__r.Name, Enrolment__r.Account__r.Gender__c, Enrolment__r.Account__r.Nationality__c From Booking__c Where Enrolment__r.Account__r.RecordType.Name = 'Student']; system.Debug('Im here!!!!'); String JSONString = JSON.serialize(bookings);//This is how we can serailize our response into JSON format system.debug(JSONString); return '{\"Records\":' +JSONString+', \"error\": \"null\", \"status\":\"SUCCESS\", \"count\":\"' + bookings.size() + '\" }'; } }
Hooray!
I've just found the problem.
By adding a Group by in the SOQL query you get a good format for the JSON string and the the Ext.Data.Model is as simple as you can see above in the code.
Cheers
Xisco
All Answers
Hooray!
I've just found the problem.
By adding a Group by in the SOQL query you get a good format for the JSON string and the the Ext.Data.Model is as simple as you can see above in the code.
Cheers
Xisco
http://extjswithsandeesh.blogspot.in/2012/07/extjs-with-salesforce-best-practices.html
how to Do the CRUD functionality in this extjs by using java script remoting