Hi, I'm trying to load data to my grid panel which resides in php using JsonStore object. But the problem is JsonStore is not getting data from php only. Can anyone tell me where i've gone wrong. Is my php file is proper or not? I'm very new to both php and extjs. please help me out.
i'm uploading the both .js and .php files. please help me out.
test.js file: - Ext.onReady(function(){
-
alert("inside onReady");
-
-
Ext.QuickTips.init();
-
-
var employee = Ext.data.Record.create([
-
{name:'firstname'},
-
{name:'lastname'}]);
-
-
//var myReader = new Ext.data.JsonReader({
-
//root:"root"
-
//},employee);
-
-
var store = new Ext.data.JsonStore({
-
id:'ID'
-
,root:'root'
-
,totalProperty:'totalCount'
-
,url:'test.php'
-
,autoLoad:true
-
//,reader:myReader
-
//,baseParams:{mod:'data',act:'getAllData'}
-
,fields:[
-
{name:'firstname', type:'string'}
-
,{name:'lastname', type:'string'}
-
]
-
});
-
-
alert("Before Displaying");
-
var n = store.getTotalCount();
-
alert(n);
-
-
var myPanel = new Ext.grid.GridPanel({
-
store: store
-
,columns:[{
-
dataIndex:'firstname'
-
,header:'First Name'
-
,width:145
-
,sortable:true
-
},{
-
dataIndex:'lastname'
-
,header:'Last Name'
-
,width:145
-
,sortable:true
-
}
-
],
-
viewConfig: {
-
autoFill: true,
-
forceFit: true
-
},
-
-
listeners:
-
{
-
render: function(grid)
-
{
-
grid.store.load();
-
}
-
}
-
});
-
-
//store.load({params:{firstname:'Vibha',lastname:'Bhagath'}});
-
-
var myWindow = new Ext.Window({
-
width:300,
-
height:300,
-
layout:'fit',
-
closable:false,
-
resizable:false,
-
items:[myPanel]
-
});
-
-
myWindow.show();
-
-
});
test.php file: - <?php
-
session_start();
-
$o = array(
-
"success" => true,
-
"records" => array( {"firstname" => "Vibha" ,
-
"lastname" => "Bhagath"},{"firstname" => "Santu" ,
-
"lastname" => "Sapi"},{"firstname" => "Shivoo" ,
-
"lastname" => "Koteshwar"})
-
);
-
$_SESSION["err"] = isset($_SESSION["err"]) ? !$_SESSION["err"] : true;
-
header("Content-Type: application/json");
-
print(json_encode($o));
-
?>
3 14713 Atli 5,058
Expert 4TB
Hey.
The PHP code you are using is invalid.
The arrays should be valid PHP arrays, not JSON formatted objects. The json_encode function handles the conversion later.
More specifically, the "firstname" and "lastname" groups are invalid. They are JSON formatted, which is not valid PHP syntax. You need to re-format them as valid PHP arrays.
how to make them php formattes array Atli.... I'm a newbie... Dont know how to make it. Can you provide me with some example or tutorial for this?
Atli 5,058
Expert 4TB
You could start by reading the manual entry for arrays. That should get you started.
But, simply put, PHP arrays start with the word "array" followed by a list of variables that the array is made up of, enclosed in parenthesis.
For example: - <?php
-
$myArray = array( 'value 1', 'value 2', 'value 3' );
-
echo $myArray[0]; // value1
-
echo $myArray[1]; // value2
-
echo $myArray[2]; // value3
-
?>
You can specify keys for the array elements by adding them in front of the value, separated by a the => operator. - <?php
-
$myArray = array(
-
'first' => 'value 1',
-
'second' => 'value 2',
-
'third' => 'value 3'
-
);
-
-
echo $myArray['first']; // value1
-
echo $myArray['second']; // value2
-
echo $myArray['third']; // value3
-
?>
Because arrays are, themselves, PHP variables, array elements can be other arrays. This makes the array multidimensional. - <?php
-
$myArray = array(
-
'first' => array( '1x1', '1x2' ),
-
'second' => array( '2x1', '2x2' )
-
);
-
echo $myArray['first'][0]; // 1x1
-
echo $myArray['first'][1]; // 1x2
-
echo $myArray['second'][0]; // 2x1
-
echo $myArray['second'][1]; // 2x2
-
?>
And there is (virtually) no limit how many arrays you can nest inside another array. You could, for example, do this: - <?php
-
$myArray = array(
-
'2009' => array( // Year
-
'01' => array( // Month
-
'01' => array( // Day
-
'00' => array( // Hour
-
'00' => array( // Minute
-
// Seconds
-
'01' => 'First second into 2009',
-
'02' => 'Second second into 2009',
-
'03' => 'Third second into 2009'
-
),
-
'01' => array(
-
'01' => 'Sixty first second into 2009',
-
'02' => 'Sixty second second into 2009',
-
'03' => 'Sixty third second into 2009'
-
)
-
)
-
)
-
)
-
)
-
);
-
?>
You need to make your array fit into this syntax, or the PHP code won't execute and only give you an error.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Bruce A. Julseth |
last post by:
When I execute this SQL statement in my PHP code, I get an error
"File '.\Address.txt' not found (Errcode: 2)"
$File = addslashes(".\Address.txt");
$SQL = "Load Data InFile \"" . $File . "\"...
|
by: Donald Tyler |
last post by:
Then the only way you can do it that I can think of is to write a PHP script
to do basically what PHPMyAdmin is trying to do but without the LOCAL in
there.
However to do that you would need to...
|
by: Ray in HK |
last post by:
What are the differences between LOAD DATA INFILE and LOAD DATA LOCAL INFILE
?
I found some web hosting company do not allow using LOAD DATA INFILE but
allow LOAD DATA LOCAL INFILE. The reason...
|
by: Uthuras |
last post by:
Greetings,
Machine : Pentium IV
Os Windows 2000 server
Product : DB2 UDB Release : 7.2
We are fail to load the following data file format into db2 database
table that has long varchar...
|
by: subaga |
last post by:
Hi,
I have to load data into a table with one of the columns defined as
NOT NULL, but the file does not have data for it. i would like to load
a constant value for this column and the constant...
|
by: nsh |
last post by:
mailing.database.mysql, comp.lang.php
subject: does "LOAD DATA" EVER work?!? I've tried EVERYTHING!
version info:
my isp is running my web page on a linux box with php ver. 4.4.1
according to...
|
by: Freedolen |
last post by:
Hi,
I have checked with some sample data and found inserting of data using 'insert command' takes more time than using 'load data' command to load data from another file. What is the process...
|
by: lanesbalik |
last post by:
hi all,
right now i'm trying to migrate from db2 running under linux to mysql v5.1.
i manage to export out the db2 structure & data into a del (ascii) file.
but when i try to load the data...
|
by: John Nagle |
last post by:
Is it possible to feed data into a LOAD DATA command in MySQL without
writing out the data to a file? It's possible to do this using the
MySQL command line and a UNIX FIFO, but that's kind of...
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |