PDA

View Full Version : no display in grid



Tascha
27 Jul 2009, 3:25 AM
At first: :((

Hello Guys,

I have a problem again.

I have a grid, which should show ip-addresses and associated devices from a database.
I'll get the IP-address from the address bar.

But when I execute the code, the grid is empty.:-? I don't get Errorcodes. Firebug answers:

({"total":"0", "results":""})


However I only start my database.php , I get an answer with the right content:

({"total":"1","results":[{"0":"12.345.67.89","ipv4_addr":"11.111.11.11","1":"ABCDEFGH","hostname":"ABCDEFGH"}]})


1. Ask for the IP-address and save it in $ip_num:









if (isset($_GET['ip']))
{
$ip_num = $_GET['ip'];
}


.................




switch($task){

case "GETIP":
get_ip_Cicle($ip_num);
break;

...............................
...............................
default:
echo "{failure:true}";
break;
}


...........



function get_ip_Cicle($ip_num){
echo $ip_num; //works fine
$query = "select inet_ntoa( ipv4 ) as ipv4_addr, hostname
from ******* where inet_ntoa(ipv4) ='$ip_num'";
$result = mysql_query($query) OR die (mysql_error());
$nbrows = mysql_num_rows($result);


if($nbrows>0){
while($rec = mysql_fetch_array($result)){

$arr[] = $rec;
}
$jsonresult = JEncode($arr);
echo '({"total":"'.$nbrows.'","results":'.$jsonresult.'})';
}
else
{
echo '({"total":"0", "results":""})';
}
}

...............................
............................... //Here is the JEncode- Funktion
..............................

And that is my grid:




Ext.onReady(function(){

teest();


var TabPanel = new Ext.TabPanel({
region: 'center',
activeTab:0,
layoutOnTabChange: true,
items:[{

title: 'Startseite',
closable:false,
autoScroll:true


},{
//That's the point:
title: '***********',
layout:'fit',
items: [test_ListingEditorGrid], closable:true,
//
}],
listeners: {
tabchange: function(newLoad){
newLoad.doLayout();
}
}
});

var item1 = new Ext.Panel({
title: 'Administration',
html: '*********;',
layout:'accordion',
animate: true,
icon: '.gif'
});

var item2 = new Ext.Panel({
title: '*********',
html: '***********;',
layout:'accordion',

cls:'empty'
});



var viewport = new Ext.Viewport({
layout: 'border',
renderTo: Ext.getBody(),
items: [{
region: 'north',
html: '<h1 class="x-panel-header">title</h1>',
icon: '/Icons/magnifier.gif',
iconCls: 'border',
autoHeight: true,
border: false,
margins: '0 0 5 0'


},{

region: 'west',
layout: 'accordion',
layoutConfig: {
animate: true
},
collapsible: true,
split: true,
width: 210,


margins: '0 0 0 5',

items: [{
title: 'Settings',
html: 'Some settings in here.',
border: false,
icon: '***********'
},{
title: 'testtest',
html: '<p>Some settings in here.</p>',
border: false,
iconCls: 'settings'

}]



},{
region: 'south',
xtype: 'panel',
html: 'Status'
}, TabPanel

]
}); //Viewport close

})


...

var test_DataStore;
var test_ColumnModel;
var test_ListingEditorGrid;


function teest(){



test_DataStore = new Ext.data.Store({



id: 'test_DataStore',
proxy: new Ext.data.HttpProxy({
url:'database.php',
method: 'POST'
}),
baseParams:{task: "GETIP"}, autoLoad: true,
reader: new Ext.data.JsonReader({
root:'results',
totalProperty:'total',
id: 'id'
},[
{name: 'hostname', type:'string', mapping:'hostname'},
{name: 'ipv4_addr', type:'string', mapping:'ipv4_addr'},
{name: 'ipv6', type:'string', mapping:'ipv6'},


]),
sortInfo: {field: 'hostname', direction: "ASC"}



});


test_ListingEditorGrid = new Ext.grid.GridPanel({ //Hier ist das Item
id: 'test_ListingEditorGrid',
store: test_DataStore,
columns: [
{header: 'hostname', dataIndex: 'hostname', width: 160},
{header: 'ipv4_addr', dataIndex: 'ipv4_addr', width: 130},
{header: 'ipv6', dataIndex: 'ipv6', width: 60},

],
viewConfig: {forceFit: false}
});

}




Somebody would like to help me? I hope my describing isn't unclear or incomplete.
:)

greetings

Tascha

Tascha
27 Jul 2009, 4:28 AM
Nobody there who can help me?

Or have I posed to complicated?

Allan
27 Jul 2009, 4:48 AM
Isn't the PHP code expecting a GET rather than a POST?

Tascha
27 Jul 2009, 4:55 AM
I'm not sure, that I understand your question.
I only work with Get, when I fetch the IP-address.

Otherwise I think, you mean that:




<?php
mysql_connect("ip-address", "user", "pass") or
die("Could not connect: " . mysql_error());
mysql_select_db("database");


if (isset($_POST['task']))
{
$task = $_POST['task'];
}



Or am I wrong?

Allan
27 Jul 2009, 5:02 AM
The ExtJS code is POSTing data but it looks like your current PHP code is looking at the $_GET array which won't contain the POSTed parameter 'ip'.

[It's a while since I did PHP programming, so may be wrong about this]

Maybe:




if (isset($_POST['ip']))
{
$ip_num = $_POST['ip'];
}



would be better?

Tascha
27 Jul 2009, 5:10 AM
Unfortunately it isn't better. But thanks for trying. :)

When I execute the database.php directly, it works definetly.

Something has to be wrong in my viewport, var test_DataStore,
var test_ColumnModel, or var test_ListingEditorGrid.

I didn't find any bug or some...

Tascha
27 Jul 2009, 9:40 PM
Other ideas, for what I can do?:s

One more aadvice?:

In Internetexplorer nothing works.
Slowly I become desperated.:(

carol.ext
28 Jul 2009, 7:26 AM
Regarding Internet Explorer problems, start by checking your code at http://jslint.com especially for extra/trailing commas. I saw one in the first bit of code.

Also take a look at the Internet Explorer section of the debugging FAQ (http://extjs.com/learn/Ext_FAQ_Debugging#Internet_Explorer).

I'll have to re-read your post to see if I can offer any other help.

carol.ext
28 Jul 2009, 7:40 AM
When you see this response : ({"total":"0", "results":""})

What GET or POST parameters are being sent? You should be able to see this in the firebug console.