Results 1 to 4 of 4

Thread: [Solved] Return data from symfony function

  1. #1
    Ext User atze's Avatar
    Join Date
    Oct 2008
    Posts
    5
    Vote Rating
    0
      0  

    Default [Solved] Return data from symfony function

    Hi,

    I dont now how to property return data from symfony function and how to use this in store.

    PHP Code:
    /**
            * Test
            * 
            * @extdirect-enable
            * @extdirect-len 0
            *
            */
        
    public function executeTest()
        {
               
    $data = array (
                    array (
    '3m Co',71.72),
                    array (
    'Alcoa Inc',29.01),          
                    array (
    'Wal-Mart Stores, Inc.',45.45)
                );
            
               
    $this->result = array('resultArray' => $data'totalCount' => count($data));
               return 
    sfView::SUCCESS;
        } 
    Response - date return as object:
    PHP Code:
    {"type":"rpc","tid":2,"action":"portal","method":"test","result":{"resultArray":[["3m Co",71.72],["Alcoa Inc",29.01],["Wal-Mart Stores, Inc.",45.45]],"totalCount":3}} 
    Store:
    PHP Code:
    var store = new Ext.data.DirectStore({
            
    directFnmyApp.portal.test,
            
    root'resultArray'// ???
            
    totalProperty'totalCount'// ???
                
    fields: [
                    {
    name'company'},
                    {
    name'price'type'float'}
                ]
            });

    var 
    grid = new Ext.grid.GridPanel({
                    
    storestore,
                        
    columns: [
                        {
    id:'company',header'Company'dataIndex'company'},
                        {
    header'Price'dataIndex'price'}
    ],
                        
    height350,
                        
    width600,
                        }); 
    Grid is empty. Only rows no data. What is wrong?
    Last edited by atze; 30 Jan 2010 at 9:55 AM. Reason: Solved

  2. #2
    Ext User cerad's Avatar
    Join Date
    Dec 2007
    Posts
    226
    Vote Rating
    0
      0  

    Default

    There is a bug in Ext.data.DataReader in that it ignores the root: name argument.
    http://www.extjs.com/forum/showthread.php?t=84398

    The bug report has a status of UNKNOWN so it's unclear if this will be addressed or if it works as intended. Certainly not fixed in 3.1.1-beta

  3. #3
    Ext User atze's Avatar
    Join Date
    Oct 2008
    Posts
    5
    Vote Rating
    0
      0  

    Default

    Hi, i have working example:
    PHP Code:
    /**
            * Test
            * 
            * @extdirect-enable
            * @extdirect-len 0
            *
            */
        
    public function executeTest()
        {
                echo 
    $this->getRequestParameter('sort');
                echo 
    $this->getRequestParameter('dir');
            
                
    $pager DbFinder::from('Portal')->paginate(1,3);
                
    $resultArray = array();
                
                foreach(
    $pager->getResults() as $res)
                    
    $resultArray[] = $res->toArray();
                
                
    $this->result = array('resultArray' => $resultArray'totalCount' => $pager->getNbResults());
                return 
    sfView::SUCCESS;
        } 
    PHP Code:
    {"type":"rpc","tid":4,"action":"portal","method":"test","result":{"resultArray":[{"Id":1,"Name":"Gory"},{"Id":2,"Name":"Morze"},{"Id":3,"Name":"Jura"}],"totalCount":3}} 
    PHP Code:
    var store = new Ext.data.DirectStore({
            
    directFnmyApp.portal.test,
          
    autoLoadtrue,
            
    idProperty'id',
            
    totalProperty'totalCount',
            
    root'resultArray',
            
    fields: [
                {
    name'Id'},
                {
    name'Name'}
            ],
            
    sortInfo: {
                
    field'id',
                
    direction'DESC'
            
    },
            
    remoteSorttrue
            
    });
            
                
    // create the Grid
                
    var grid = new Ext.grid.GridPanel({
                    
    storestore,
                        
    columns: [
                        {
    header'ID'width160sortabletruedataIndex'Id'},
                        {
    header'Name'width75sortabletruedataIndex'Name'}
                    ],
                        
    stripeRowstrue,
                        
    frametrue,
                        
    height350,
                        
    width960,
                        
    title'Portal',
                        
    columnLinestrue
                
    }); 
    This works. I use remoteSort, but POST not send 'dir' and 'sort' value.
    PHP Code:
    {"action":"portal","method":"test","data":null,"type":"rpc","tid":3
    What is wrong?

  4. #4
    Ext User atze's Avatar
    Join Date
    Oct 2008
    Posts
    5
    Vote Rating
    0
      0  

    Default

    I'm stupid.

    PHP Code:
    /**
            * Test
            * 
            * @extdirect-enable
            * @extdirect-len 2 <------------- before 0, no post data
            *
            */ 
    Solved

Posting Permissions

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