PDA

View Full Version : needed help: grid



pradeep_123
21 Feb 2007, 5:51 AM
Hi,

I have a grid with some contents and I want to display the detailed information when I click on a row. ie it should be dispalyed as a seperate page in another div some where. How it is possible ?

BernardChhun
21 Feb 2007, 6:46 AM
You have to suscribe a function to the rowClick event of the grid.

that particular function will have the following signature:



function rowClick(grid, rowIndex, e){

}
when that function happens, you will know a row has been selected and you just need to react accordingly.
As for me I use a template to overwrite the details' region with the data from the selected row.

Animal
21 Feb 2007, 8:02 AM
The OP finds Bobafart's code confusing........... http://www.timetriallingforum.co.uk/style_emoticons/default/HeadBang.gif

BernardChhun
21 Feb 2007, 8:18 AM
The OP finds Bobafart's code confusing........... http://www.timetriallingforum.co.uk/style_emoticons/default/HeadBang.gif

:D

was my response confusing too? I answered the same thing as in bobafart's post... :?

pradeep_123
22 Feb 2007, 3:42 AM
Yaa , I have done as u said,


var onRowClick = function(grid, rowIndex, e) {
var itemId= grid.getSelectedRowId();
detailedInfo.load('res.php', {id: itemId});
}
grid.addListener('rowclick', onRowClick);
grid.getSelectionModel().selectFirstRow();

Here what I understood is that(I dont know it is correct) when I click on a row , the corresponding Id will be passed to res.php and it will fetch data from table using that Id, and it will be displayed in that page itself., and we 'll load the same page.
is that OK?

If it is so, How ItemId is passed to res.php? How res.php receive the Id? how this data transfer occure between javascript and PHP. This is what I am confused with

BernardChhun
22 Feb 2007, 4:36 AM
Yaa , I have done as u said,


var onRowClick = function(grid, rowIndex, e) {
var itemId= grid.getSelectedRowId();
detailedInfo.load('res.php', {id: itemId});
}
grid.addListener('rowclick', onRowClick);
grid.getSelectionModel().selectFirstRow();

Here what I understood is that(I dont know it is correct) when I click on a row , the corresponding Id will be passed to res.php and it will fetch data from table using that Id, and it will be displayed in that page itself., and we 'll load the same page.
is that OK?

If it is so, How ItemId is passed to res.php? How res.php receive the Id? how this data transfer occure between javascript and PHP. This is what I am confused with

there are 2 main ways to communicate with a web page. the 2 methods are called POST and GET.
some things to read about it : http://en.wikipedia.org/wiki/HTTP

your PHP page should be able to extract one of those ways using : $_POST["id"] or $_GET["id"]

the string inside the brackets is the name of the POST or GET key. Since your parameter for res.php is {id: itemId}, id will be the key you'll be looking for.

pradeep_123
22 Feb 2007, 5:09 AM
Thank u for replying,

Yaa I know get and post , it's all php side right ,
but what I would like to know is how can I pass ItemId from grid to res.php?

BernardChhun
22 Feb 2007, 5:13 AM
Thank u for replying,

Yaa I know get and post , it's all php side right ,
but what I would like to know is how can I pass ItemId from grid to res.php?

you are doing exactly that when you pass the parameters in the load() function. it's not working?

install Firefox's firebug plugin and check what is the data that is passed to your php page.

Animal
22 Feb 2007, 5:19 AM
http://ec3.images-amazon.com/images/P/B0009PD2FQ.01._SCMZZZZZZZ_.jpg :?:

BernardChhun
22 Feb 2007, 5:31 AM
http://ec3.images-amazon.com/images/P/B0009PD2FQ.01._SCMZZZZZZZ_.jpg :?:

... :x calm down Animal, I'll answer his questions ok? don't ya feel the newbie's pain here? I'm quite happy you didn't answer my posts that way you know...

pradeep_123
22 Feb 2007, 7:07 AM
var onRowClick = function(grid, rowIndex, e) {
var itemId= grid.getSelectedRowId();
detailedInfo.load('res.php', {id: itemId}); // this is to be passed
}
grid.addListener('rowclick', onRowClick);
grid.getSelectionModel().selectFirstRow();


php:


$query=" select * from table1 where itemid=$itemId"; // ItemId should be received here
$result=mysql_query($query);
$array1=mysql_fetch_array($result);

This is my question.
How the itemId is received in the php page?
I hope u r clear now?

BernardChhun
22 Feb 2007, 7:20 AM
var onRowClick = function(grid, rowIndex, e) {
var itemId= grid.getSelectedRowId();
detailedInfo.load('res.php', {id: itemId}); // this is to be passed
}
grid.addListener('rowclick', onRowClick);
grid.getSelectionModel().selectFirstRow();


php:


$query=" select * from table1 where itemid=$itemId"; // ItemId should be received here
$result=mysql_query($query);
$array1=mysql_fetch_array($result);

This is my question.
How the itemId is received in the php page?
I hope u r clear now?



// HERE!!
$itemId = $_POST["id"]; // if that doesn't work try $_GET["id"]
$query=" select * from table1 where itemid=$itemId"; // ItemId should be received here
$result=mysql_query($query);
$array1=mysql_fetch_array($result);

Bobafart
22 Feb 2007, 7:39 AM
http://ec3.images-amazon.com/images/P/B0009PD2FQ.01._SCMZZZZZZZ_.jpg :?:

Animal, that is inappropriate and does nothing for Jack Solcum.

pradeep is a new person to this library. If you don't want to invite him with open arms then being condescending towards him only serves to be destructive and turn new people away from Jack's framework.

I am writing this because (though you have helped me in the past) you have also been condescending and rude towards me so I thought I would finally speak up.

Not everyone who posts in this forum will be at your programming level.

Please stop being rude/condescending/not helpful to others.

Animal
22 Feb 2007, 9:22 AM
Well I have a headache, I don't know about you! Just thought I'd share some painkillers!