Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: problem loading values to my extjsgrid

  1. #1

    Default problem loading values to my extjsgrid

    problem in loading values to my extjs grid

    following is the code which i have written

    Code:
    Ext.onReady(function() {
    	Ext.QuickTips.init();
    	var store=new Ext.data.JsonStore({
    		 ele:document.getElementById("1"),
    		  url: 'http://localhost:8080/JsonExample/get.html', 
    		  root: 'employee',
    		  idProperty: 'empid',
    		  fields: [{name: 'empid', type: 'int'}, {name: 'empname'}],
    		  autoLoad: true
    	});
        var colModel = new Ext.grid.ColumnModel([
            {header: "empid", width: 120, sortable: true, dataIndex: 'empid'},
            {header: "empname", width: 90, sortable: true, dataIndex: 'empname'}
        ]);
    
        var grid = new Ext.grid.GridPanel({ height:200, width:600, ds:store, cm: colModel});
        grid.render(document.body);
        grid.getSelectionModel().selectFirstRow();
        
    });
    this is my piece of java code
    here the employee object is marshalled to json object

    Code:
    	JSONArray json=new JSONArray();
    		JSONObject JSONobj=new JSONObject();
    		while(empitr.hasNext()){
    			JSONObject jobj=new JSONObject();
    			Employee empl=new Employee();
    			empl=empitr.next();
    			jobj.put("empid",empl.getEmpid());
    			jobj.put("empname",empl.getEmpname());
    			json.add(jobj);
    		}
    		JSONobj.put("employee",json.toString());
    this is the json response from the server
    {"employee":[{"empid":123,"empname":"kiran kumar"},{"empid":1231,"empname":"kiran"}]}

    all the the things are perfect but i donno why the values are not being loaded to json store
    still i doubt on the url in the Json store


    help me please
    thanks in advance

  2. #2
    Sencha User
    Join Date
    Aug 2010
    Posts
    177

    Default

    Hello,

    Are you using firebug or any debugger tool? If you do, what error do you get?

    If you need to load data to grid's store, why don't you try JSON reader with a proxy?
    --
    Mehmet ad?rc?

  3. #3

    Default

    i debugged using firebug dint get any result
    json reader with a proxy dint give me result

  4. #4
    Sencha User
    Join Date
    Aug 2010
    Posts
    177

    Default

    json reader is smt like this:

    PHP Code:
        var reader=new Ext.data.JsonReader({
        },[
            {
    name'id'},
            {
    name'name'mapping'name'},
            {
    name'companyId'mapping'companyId' },
            {
    name'fleetId'mapping'fleetId'},
            {
    name'parentId'mapping'parentId'},
            {
    name'code'},
            {
    name'sms1'},
            {
    name'sms2'},
            {
    name'sms3'},
            {
    name'link'}        
        ]
        );
        var 
    store=new Ext.data.Store({
            
    id'searchStore',
            
    proxy : new Ext.data.HttpProxy({
                
    url'do',
                
    method'POST'
            
    }),
            
    baseParams: {
                
    op'searchGroupCmd'
            
    },
            
    reader:reader
        
    }); 
    --
    Mehmet ad?rc?

  5. #5

    Default

    not working

  6. #6
    Sencha User
    Join Date
    Aug 2010
    Posts
    177

    Default

    Hello again,

    If I understand wrong please warn me, aren't you tring to load a grids data via json request?

    What errors do you get? If you don't get any errors, at net tab do you see the request related with JSON?

    If you don't, are you sure that you use the load function of the store?
    --
    Mehmet ad?rc?

  7. #7

    Default

    yes i am requesting the json object and load it to grid
    i dont get any errors
    i debugged my code using firebug
    not getting any kind of result

  8. #8

    Default

    {"employee":[{"empid":123,"empname":"kiran kumar"},{"empid":1231,"empname":"kiran"}]}

    this is the server response

  9. #9
    Sencha User
    Join Date
    Aug 2010
    Posts
    177

    Default

    PHP Code:
    Ext.onReady(function() {
        
    Ext.QuickTips.init();
        var 
    store=new Ext.data.JsonStore({
             
    ele:document.getElementById("1"),
              
    url'http://localhost:8080/JsonExample/get.html'
              
    root'employee',
              
    idProperty'empid',
              
    fields: [{name'empid'type'int'}, {name'empname'}]
        });
        var 
    colModel = new Ext.grid.ColumnModel([
            {
    header"empid"width120sortabletruedataIndex'empid'},
            {
    header"empname"width90sortabletruedataIndex'empname'}
        ]);

        var 
    grid = new Ext.grid.GridPanel({ height:200width:600ds:storecmcolModel});
        
    grid.render(document.body);
        
    grid.store.load();
        
    grid.getSelectionModel().selectFirstRow();
        
    }); 
    try this plz
    --
    Mehmet ad?rc?

  10. #10

    Default

    Quote Originally Posted by mcadirci View Post
    PHP Code:
    Ext.onReady(function() {
        
    Ext.QuickTips.init();
        var 
    store=new Ext.data.JsonStore({
             
    ele:document.getElementById("1"),
              
    url'http://localhost:8080/JsonExample/get.html'
              
    root'employee',
              
    idProperty'empid',
              
    fields: [{name'empid'type'int'}, {name'empname'}]
        });
        var 
    colModel = new Ext.grid.ColumnModel([
            {
    header"empid"width120sortabletruedataIndex'empid'},
            {
    header"empname"width90sortabletruedataIndex'empname'}
        ]);

        var 
    grid = new Ext.grid.GridPanel({ height:200width:600ds:storecmcolModel});
        
    grid.render(document.body);
        
    grid.store.load();
        
    grid.getSelectionModel().selectFirstRow();
        
    }); 
    try this plz
    sorry friend even this is not working
    i could not trace out whats happening

Page 1 of 2 12 LastLast

Similar Threads

  1. problem loading values to my extjs grid using json
    By kirankumar1231 in forum Ext 2.x: Help & Discussion
    Replies: 9
    Last Post: 31 Mar 2014, 4:59 AM
  2. problem loading values to my grid
    By kirankumar1231 in forum Ext 3.x: Help & Discussion
    Replies: 9
    Last Post: 16 Mar 2011, 3:28 AM
  3. problem loading values to my extjs grid using json
    By kirankumar1231 in forum Ext 3.x: Help & Discussion
    Replies: 0
    Last Post: 15 Mar 2011, 12:50 AM
  4. [FIXED-532][3.1] Problem loading values into store
    By mikecar in forum Ext 3.x: Bugs
    Replies: 4
    Last Post: 23 Feb 2010, 11:16 AM
  5. Problem loading values in 2 forms one after the other
    By angeldimitrov in forum Ext 2.x: Help & Discussion
    Replies: 10
    Last Post: 25 May 2008, 3:44 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •