1. #1
    Sencha User
    Join Date
    Feb 2012
    Posts
    9
    Vote Rating
    0
    ONeill is on a distinguished road

      0  

    Default Answered: data store wont add data transmitted via PHP

    Answered: data store wont add data transmitted via PHP


    Hello guys,

    i dispair at my problem I think its only a simple bug i have created in the code, but i don't find them
    The Problem:
    I have a data store:
    PHP Code:
    Ext.create('Ext.data.Store', {            id:'romStoreid',            storeId:'romStore',            fields:['id', 'name'],            data:{'items':[                <?php                    $sql mysql_query('SELECT id, name, lasttime, device FROM content WHERE access = "1"');                    if (mysql_num_rows($sql) == 0) {                        echo 'No resources found.<br>';                    }                    else {                        while ($c mysql_fetch_array($sql)) {                            $device mysql_query('SELECT deviceName FROM devices WHERE deviceID = "'.mysql_real_escape_string($c["device"]).'"');                            $device mysql_fetch_array($device);                            echo "{ 'id': '".$c[id]."',  \"name\":\"".$device[deviceName]." ".$c[name]."\"  },";                        }                    }                ?>            ]},            proxy: {                type: 'memory',                reader: {                    type: 'json',                    root: 'items'                }            }        });
    and the data store is used for my grid:
    PHP Code:
    {                    id'testernavpanel',                    title'Available Roms',                    items: [{                        xtype'grid',                        title'',                        id'romGrid',                        storeExt.data.StoreManager.lookup('romStore'),                        columns: [                            { header'ID',  dataIndex'id'hiddentruehideablefalse},                            { header'Name'dataIndex'name'width240 }                        ],                        width250,                        renderToExt.getCmp('testernavpanel'),                    }],                    iconCls'info'                
    Now i have a refresh button. The task of this button is to delete all values in the store and load them new from another php file using ajax:
    PHP Code:
    Ext.Ajax.request({        url'expand.php?view=testers_new',        method'GET',        callback: function(optionssuccessresponse) {            var data response.responseText;            a.getStore().removeAll();            a.getStore().add(data);            console.log(data);        }    }); 
    The new data come from this php code:
    PHP Code:
    $sql mysql_query('SELECT id, name, device FROM content WHERE access = "1"');                if (mysql_num_rows($sql) == 0) {                    echo 'No resources found.<br>';                }                else {                    while ($c mysql_fetch_array($sql)) {                        $device mysql_query('SELECT deviceName FROM devices WHERE deviceID = "'.mysql_real_escape_string($c["device"]).'"');                        $device mysql_fetch_array($device);                        echo "{id: '".$c[id]."',  name: '".$device[deviceName]." ".$c[name]."'}, ";                    }                    echo "{id:'', name:\"\"}";                } 
    Now the big problem is, that after i clicked on refresh, all values will be removed, ok. But then only one empty value is added.
    The json encoded data is correct transmitted from the php file, i have copied the data from the console and added them to the "a.getStore().add(data);" instead of "data". Then all is ok, and the new data is inserted as the new values.

    Has anyone of you an idea why the data of the php file inserted in the store?
    Thanks for help and if any more code is needed, please ask

    Greetings

  2. I could not read your first post. Based on your second post, did you try putting the reader on your proxy instead of on your store?

  3. #2
    Sencha User
    Join Date
    Feb 2012
    Posts
    9
    Vote Rating
    0
    ONeill is on a distinguished road

      0  

    Default


    Hello,

    i have test myself and the following, not working code:
    The Store:
    Code:
    var romStore = new Ext.data.Store({
    			proxy: new Ext.data.HttpProxy({
    				  url:'expand.php?view=testers_new',
    				  method: 'GET'
    			}),
    			fields: ['id', 'name'],
    			reader: new Ext.data.JsonReader({
    				id: 'JSON_id',
    				totalProperty: 'totalCount',
    				root: "data",
    				fields:
    				[{name: 'id', type: 'int', mapping: 'id'},
    				{name: 'name', type: 'string', mapping: 'name'}
    				]
    			}),
    		});
    		
    		romStore.load();
    The PHP Code:
    Code:
    $sql = mysql_query('SELECT id, name, device FROM content WHERE access = "1"');				if (mysql_num_rows($sql) == 0) {
    					echo 'No resources found.<br>';
    				}
    				else {
    					$i = 1;
    					while ($c = mysql_fetch_array($sql)) {
    						$device = mysql_query('SELECT deviceName FROM devices WHERE deviceID = "'.mysql_real_escape_string($c["device"]).'"');
    						$device = mysql_fetch_array($device);
    						//echo "{id: '".$c[id]."',  name: '".$device[deviceName]." ".$c[name]."'}, ";
    						$data[] = array(
    							'id' => $c['id'],
    							'name' => $device['deviceName'].' '.$c['name'],
    							);
    					}
    					$count = mysql_num_rows($sql);
    					$myData = array('data' => $data, 'totalCount' => $count);
    					echo json_encode($myData);
    				}
    An example JSON string:
    Code:
    {"data":[{"id":"7","name":"HTC Wildfire S .sense"},{"id":"8","name":"HTC Wildfire S Auto-Installers GUI"},{"id":"21","name":"HTC Wildfire S MIUI Port"},{"id":"22","name":"HTC Wildfire S CM7 Nighlys"},{"id":"24","name":"HTC Wildfire S MIUI v4"},{"id":"25","name":"HTC Wildfire S CM9 for Marvel"},{"id":"44","name":"HTC Wildfire S bgnb g"}],"totalCount":7}
    I hope, that somebody can help, idk what i can do now

  4. #3
    Sencha User carol.ext's Avatar
    Join Date
    Jun 2007
    Location
    Littleton, Colorado, USA
    Posts
    673
    Answers
    16
    Vote Rating
    20
    carol.ext will become famous soon enough carol.ext will become famous soon enough

      1  

    Default


    I could not read your first post. Based on your second post, did you try putting the reader on your proxy instead of on your store?

  5. #4
    Sencha User
    Join Date
    Feb 2012
    Posts
    9
    Vote Rating
    0
    ONeill is on a distinguished road

      0  

    Default


    Hmm, good idea. But then i must load the extjs framework in the php file, or?

  6. #5
    Sencha User
    Join Date
    Feb 2012
    Posts
    9
    Vote Rating
    0
    ONeill is on a distinguished road

      0  

    Default


    Sorry for the silly last post from me I was online with my smartphone and i think i haven't read the help post really good

    I have moved the reader to the proxy and now the store updates! THANKS FOR YOUR VERY GOOD HELP! I was so silly to not see this problem

Thread Participants: 1

Tags for this Thread

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi