I am extremely new to EasyUI and to Web Development in general so forgive me if this question is obvious to most people. I've been stuck on this issue for 2-3 weeks and am finally ready to admit I need help.
I am having problems populating datagrid and propertygrid's using the 'url:""' parameter. My workaround until now was to use the 'data: propgrid' method instead of the url method.
This of course requires me to create and populate the variable using PHP at page load time and that to refresh the data, I have to refresh the entire page. (very undesirable!)
I use a Powershell script on the back end which interfaces with a number of systems to collect the information I want to display. The powershell script produces JSON-formatted output.
I
want to be able to click a button on my page which creates the property grid and uses the URL property to invoke a .php script to invoke the powershell script to collect the data.
function addpg() {
$('#pg').propertygrid({
url: 'propgrid.php?arg1=value1&arg2=value2',
showGroup: true,
scrollbarSize: 0
});
};
I've tried a million variations of this and for the life of me I can't get it to work when trying to generate the data 'live'. It just fails silently. If I mis-type the propgrid.php, i can see in the console.log that a 404 error is generated (so I know it is being called), but if everything is spelled correctly, I get no error - and also no data displayed.
This mechanism works fine if I change it to:
url: 'propgrid_data.json'
and I have the data stored in the above named file on my web-server - but NOT if I try to generate the data on-the-fly.
For sake of an example; One of the property grids is meant to display a list of Windows Services running on a remote server and the status of each (ie: Stopped, Running, StartPending, etc).
Powershell collects the information in an object, and I generate the output from that object with something like:
$comma=",`r`n"
$outfile="[`r`n"
$infile|foreach {
$name = $infile.name;$value=$infile.value;$group=$infile.group
$outfile = "$outfile`r`n{`"name`":`"$name`",`"value`":`"$value`",`"group`":`"$group`"}$comma"
}
$outfile = "$outfile`r`n]"
(There is also logic in the loop to determine it is the last record and set the value of $comma to blank)
After many failures, I added a line after the loop to save a copy of my output to disk:
$outfile|set-content "C:\Apache24\htdocs\testing\propgrid_data.json"
The content of the .json file is identical to the results returned by the PHP page however;
- the grid is populated correctly if I set url to look directly to the .json file, but
- the grid does
NOT get populated if I set it to use the .php file
I've verified that the lines end with crlf in both the web-page and the file.
I've tried adding the <html> and <body> tags to the html output and I've tried just generating the raw output with no html elements.
I've confirmed that the encoding of the file and the web-page output are both UTF-8.
Here is a sample of how my .json file looks and also how the output from invoking the .php file looks. If I retrieve both via the web-browser and choose 'View Source', the results are identical.
[
{"status":"Running","servicename":"Service1"},
{"status":"Running","servicename":"Service2"},
{"status":"Stopped","servicename":"Service3"},
{"status":"Running","servicename":"Service4"}
]
I just don't get it. What do I need to do to make the property grid control accept and display the output from a .PHP page???
Please help!