Delphi For PHP Forums    


Go Back   Delphi-PHP Forums > Delphi4PHP NNTP Newsgroups > embarcadero.public.delphiphp.vclforphp.components.using
Forum Jump Register FAQ Members List Downloads Search Today's Posts Mark Forums Read

embarcadero.public.delphiphp.vclforphp.components.using This group is for all discussion about the use of VCL for PHP components.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 4th June 2008, 16:50
fredrm's Avatar
D4PHP User
 
Join Date: Jun 2008
Posts: 45
fredrm is on a distinguished road
Default Get a row value form dbrepeater

Hi folks,

I'm having some headaches with the dbrepeater.

The problems is... I have a dbrepeater with 2 labels.

One label is showing the dbresults and the other is a lablel with caption Select that onclick it will get the code of the selected row for and use it on another sql_query.

Thanks!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 4th June 2008, 17:37
405hp's Avatar
Firebug Fanatic
 
Join Date: Dec 2007
Location: State of Confusion
Posts: 3,456
405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute
Default

I haven't messed with it much but these snippets will get the caption of a button or label in the dbrepeater.

Quote:
//converting browser differences target= firefox or IE

function Button1JSClick($sender, $params)

{

?>
var target = event.target || event.srcElement;
alert(target.value);

<?php

}
//click on label and get caption
function Label1JSClick($sender, $params)
{

?>
var target = event.target || event.srcElement;
alert(target.innerHTML);
<?php

}
From that you will have to make your determinations.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 10th June 2008, 04:28
fredrm's Avatar
D4PHP User
 
Join Date: Jun 2008
Posts: 45
fredrm is on a distinguished road
Default

not solved... because i wanna get the value of that sql row... not the value of the label...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 10th June 2008, 12:00
405hp's Avatar
Firebug Fanatic
 
Join Date: Dec 2007
Location: State of Confusion
Posts: 3,456
405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute
Default

Then you must make the value of the label equal to something that allows you to determine your sql row.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 16th June 2008, 18:37
D4PHP User
 
Join Date: Jun 2007
Location: Naples, FL
Posts: 40
lifeform is on a distinguished road
Default

It would be nice to be able to use something like the Tag property of the label component to store the record id of each record in the dbrepeater. That way the caption can display something appropriate (in my case a person's name) rather than just an id number. The problem is, I can't figure out how to access the label's tag from the client side.

I suppose I could make the label's caption something like "Bloggs, Fred [32441]" and use javascript to parse the string for the number in brackets, but it's easy enough to confuse my users without displaying strange numbers in front of them.

Does anyone know how to access the tag property from javascript?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 16th June 2008, 18:49
405hp's Avatar
Firebug Fanatic
 
Join Date: Dec 2007
Location: State of Confusion
Posts: 3,456
405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute
Default

The tag property is php only. It doesn't transfer to the javascript side at all.

There are multiple ways of doing something like that though.

Examples:
You can create a js object (key:value pairs) that stores your needed info.
You can use hiddenFields that have the same naming conventions so you can access them.
If you are using true js objects (like textfield or bitbutton) you can create a tag on the fly after it has been created. echo "textfield1.mynewproperty=32441;";
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 16th June 2008, 19:08
D4PHP User
 
Join Date: Jun 2007
Location: Naples, FL
Posts: 40
lifeform is on a distinguished road
Default

Hi 405hp, and thanks for your post. Yes, I'm using hidden fields for other areas where I want to transfer data between the client and server side, but the problem here is that the label is in a dbrepeater. As far as I understand it, that means it's not possible to access the label directly. Until I saw your post earlier in this thread, I didn't even know you could use something like
Code:
var target = event.target || event.srcElement;
to get the caption value.

The problem with key, value pairs is that I need the caption to display the value, which in the case of names is not guaranteed to be unique. If I display the key, then I'll just confuse my users, although it would function perfectly.

Do you know if there's a way to add a property to a label inside a dbrepeater in php that's available to javascript when it gets to the client side?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 16th June 2008, 19:39
405hp's Avatar
Firebug Fanatic
 
Join Date: Dec 2007
Location: State of Confusion
Posts: 3,456
405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute
Default

Quote:
Originally Posted by lifeform View Post
The problem with key, value pairs is that I need the caption to display the value, which in the case of names is not guaranteed to be unique. If I display the key, then I'll just confuse my users, although it would function perfectly.
Make the key=value and value=key then to use it
key=jsobject.labelcaption
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 16th June 2008, 20:02
D4PHP User
 
Join Date: Jun 2007
Location: Naples, FL
Posts: 40
lifeform is on a distinguished road
Default

Thanks again, but I'm not quite with you. In the dbrepeater, I display the name (and then some other fields) and there could be a hundred or so in the list. The data comes from a query like "SELECT id, CONCAT(lastname,', ',firstname) AS fullname FROM customers", so the key is the id and the value is fullname, and there are 100 or so of the key/value pairs.

The label caption is set by the DataSource and DataField properties of the dbrepeater to "fullname" so that the names are displayed.

Using your code, I can do something like this on the label's JS OnClick event:
Code:
var target = event.target || event.srcElement;
alert(target.innerHTML);
That gives me the fullname, but what I need is the id. If I set the caption value to be id, then the dbrepeater will obviously display a list of numbers rather than names.

How could I get the id?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 16th June 2008, 20:42
405hp's Avatar
Firebug Fanatic
 
Join Date: Dec 2007
Location: State of Confusion
Posts: 3,456
405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute
Default

OK, visualize this pseudo code:
On the server in php code you either store an array as the labels are created or just run a loop with sql query later.

Either way in one of the forms later events (onaftershow?) do a loop output of the value:key pairs.

PHP Code:
echo '<script>';
echo 
'myinfo=[];';
loop control
{
echo 
"myinfo.$value=$key;";
//this is the same as
//echo "myinfo.Bloggs_Fred=32441;";
}
echo 
'</script>'
Then in the jsonclick event extract the name from the labels value convert it to last_first and access it

Code:
var convertedname=string_manipulated(target.innerHTML );
alert(myinfo.convertedname);
//this is the same as
//alert(myinfo.Bloggs_Fred); //which displays 32441

Last edited by 405hp; 16th June 2008 at 20:44.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT +1. The time now is 08:09.




Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0 ©2009, Crawlability, Inc.
Copyright © 2004 - 2009, G&J Solutions Ltd. All Rights Reserved. terms of use