CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> Archive -> CodeChargeStudio.Discussion

 Here's EditableGrid in PHP!!!

Print topic Send  topic

Author Message
DonB
Posted: 08/12/2002, 5:44 PM

I think I've gotten it squared away. To minimize the impact on this group,
I've only posted my event module EditableGrid_Event.php:
There are several "echo" lines in there to help visualize what's happening.
You'll want to take them out.

One BIG note: Convert the ASP version, by changing the project from "ASP"
to PHP with templates". THEN BE SURE TO CHANGE THE HTML FILE so the <FORM>
tag refers to the .php file - it will remain .asp until you change it by
hand. That is what was hosing me up - I finally realized submitting the php
page was submitting it to the asp page! Not very cool, but very confusing
(the "live" window does not show the URL, so it was easy to miss this).

Don Anderson also pointed me to the use of GetValue and SetValue. Thank!

Don

Don't save the following as your event file. Open your project, go to your
EditableGrid.php and add three events: (1) BeforeShow on the label "price",
(2) BeforeShow on the checkbox, and (3) AfterInitialize on the grid itself.

Then paste my corresponding code into your event routines (this will keep
the "markers" correct (those things that start with "@")

There are two things that need improving upon: (1) ensuring the grid obeys
security for update/delete actions and (2) I think I'd put hidden checkboxes
on the grid, then add client-side code to set these to "ON" when the price
is changed, This way, only the rows that need updating could be updated -
by seeing if the checkbox is indeed checked. The original version merely
updates every row everytime you submit. Not efficient!

don


function bs_items_price_BeforeShow() { //bs_items_price_BeforeShow
@23-21B16B84

//Custom Code @27-2A29BDB7
// -------------------------
global $bs_items;
$bs_items->price->SetValue("<input type=textbox name='" .
$bs_items->item_id->GetValue() . "' value='" . $bs_items->price->Value . "'
size=8>");
// -------------------------
//End Custom Code

} //Close bs_items_price_BeforeShow @23-FCB6E20C

function bs_items_to_be_deleted_BeforeShow() {
//bs_items_to_be_deleted_BeforeShow @25-EED1ED5A

//Custom Code @28-2A29BDB7
// -------------------------
global $bs_items;
$bs_items->to_be_deleted->SetValue("<input type=checkbox name=del." .
$bs_items->item_id->GetValue() . " value=OFF>");
// -------------------------
//End Custom Code

} //Close bs_items_to_be_deleted_BeforeShow @25-FCB6E20C

function Page_AfterInitialize() { //Page_AfterInitialize @1-56434BCA

//Custom Code @33-2A29BDB7
// -------------------------
global $bs_items;
global $DBinternet;

global $QUERY_STRING;
if (isset($QUERY_STRING)) {
echo ">>" . $_SERVER['QUERY_STRING'] . "<br>";
}
else {
echo "<< Not Set<br>";
}
if (isset($QUERY_STRING)) {
$qstring = explode("&", $QUERY_STRING);
foreach ($qstring as $arr => $id) {
// echo "id$=" . $id . "<br>";
$itemN = explode("=",$id);
echo "[0]=" . $itemN[0] . ", [1]=" . $itemN[1] . "<br>";
if (isset($itemN[1]) and isset($itemN[1])) {
if ( is_numeric($itemN[0]) and
is_numeric($itemN[1]) ) {
// Do an UPDATE of this item
$strUpdate = "UPDATE bs_items SET price=" . $itemN[1] . " WHERE item_id
= " . $itemN[0];
$DBinternet->query($strUpdate);
echo $strUpdate . "<br>";
}
elseif (strpos($itemN[0],".") > 0){
// Do a DELETE
echo "DELETE " . $itemN[0] . "<br>";
$itemN[0] = str_replace("del.","",$itemN[0]); // Extract just the item
number (e.g. extract "123" from "del.123");
$DBinternet->query("DELETE FROM bs_items where item_id=" . $itemN[0]);
}
}

} //foreach
} // if isset
// -------------------------
//End Custom Code

} //Close Page_AfterInitialize @1-FCB6E20C

?>


Don Anderson
Posted: 08/12/2002, 10:09 PM

Hi Don,

Followed your instructions and have the example going. Very cool!
Switched over to mysql.

Now I'll try writing one for my own project.
Thanks heaps.

Cheers,
Don Anderson


"DonB" <7432D63DBB01D03A196B1EDD80E8@comcast.net> wrote in message
news:aj9kpb$41t$1@news.codecharge.com...
> I think I've gotten it squared away. To minimize the impact on this
group,
> I've only posted my event module EditableGrid_Event.php:
> There are several "echo" lines in there to help visualize what's
happening.
> You'll want to take them out.
>
> One BIG note: Convert the ASP version, by changing the project from "ASP"
> to PHP with templates". THEN BE SURE TO CHANGE THE HTML FILE so the
<FORM>
> tag refers to the .php file - it will remain .asp until you change it by
> hand. That is what was hosing me up - I finally realized submitting the
php
> page was submitting it to the asp page! Not very cool, but very confusing
> (the "live" window does not show the URL, so it was easy to miss this).
>
> Don Anderson also pointed me to the use of GetValue and SetValue. Thank!
>
> Don
>
> Don't save the following as your event file. Open your project, go to
your
> EditableGrid.php and add three events: (1) BeforeShow on the label
"price",
> (2) BeforeShow on the checkbox, and (3) AfterInitialize on the grid
itself.
>
> Then paste my corresponding code into your event routines (this will keep
> the "markers" correct (those things that start with "@")
>
> There are two things that need improving upon: (1) ensuring the grid obeys
> security for update/delete actions and (2) I think I'd put hidden
checkboxes
> on the grid, then add client-side code to set these to "ON" when the price
> is changed, This way, only the rows that need updating could be updated -
> by seeing if the checkbox is indeed checked. The original version merely
> updates every row everytime you submit. Not efficient!
>
> don
>
>
> function bs_items_price_BeforeShow() { //bs_items_price_BeforeShow
> @23-21B16B84
>
> //Custom Code @27-2A29BDB7
> // -------------------------
> global $bs_items;
> $bs_items->price->SetValue("<input type=textbox name='" .
> $bs_items->item_id->GetValue() . "' value='" . $bs_items->price->Value .
"'
> size=8>");
> // -------------------------
> //End Custom Code
>
> } //Close bs_items_price_BeforeShow @23-FCB6E20C
>
> function bs_items_to_be_deleted_BeforeShow() {
> //bs_items_to_be_deleted_BeforeShow @25-EED1ED5A
>
> //Custom Code @28-2A29BDB7
> // -------------------------
> global $bs_items;
> $bs_items->to_be_deleted->SetValue("<input type=checkbox name=del." .
> $bs_items->item_id->GetValue() . " value=OFF>");
> // -------------------------
> //End Custom Code
>
> } //Close bs_items_to_be_deleted_BeforeShow @25-FCB6E20C
>
> function Page_AfterInitialize() { //Page_AfterInitialize @1-56434BCA
>
> //Custom Code @33-2A29BDB7
> // -------------------------
> global $bs_items;
> global $DBinternet;
>
> global $QUERY_STRING;
> if (isset($QUERY_STRING)) {
> echo ">>" . $_SERVER['QUERY_STRING'] . "<br>";
> }
> else {
> echo "<< Not Set<br>";
> }
> if (isset($QUERY_STRING)) {
> $qstring = explode("&", $QUERY_STRING);
> foreach ($qstring as $arr => $id) {
> // echo "id$=" . $id . "<br>";
> $itemN = explode("=",$id);
> echo "[0]=" . $itemN[0] . ", [1]=" . $itemN[1] . "<br>";
> if (isset($itemN[1]) and isset($itemN[1])) {
> if ( is_numeric($itemN[0]) and
> is_numeric($itemN[1]) ) {
> // Do an UPDATE of this item
> $strUpdate = "UPDATE bs_items SET price=" . $itemN[1] . " WHERE
item_id
> = " . $itemN[0];
> $DBinternet->query($strUpdate);
> echo $strUpdate . "<br>";
> }
> elseif (strpos($itemN[0],".") > 0){
> // Do a DELETE
> echo "DELETE " . $itemN[0] . "<br>";
> $itemN[0] = str_replace("del.","",$itemN[0]); // Extract just the item
> number (e.g. extract "123" from "del.123");
> $DBinternet->query("DELETE FROM bs_items where item_id=" . $itemN[0]);
> }
> }
>
> } //foreach
> } // if isset
> // -------------------------
> //End Custom Code
>
> } //Close Page_AfterInitialize @1-FCB6E20C
>
> ?>
>
>
>

RonB
Posted: 08/13/2002, 3:08 AM

I'll be trying this as soon as I'm up to it, just came back from hospital so
'll need a few day's of rest before doing anything major :-)

RonB


"DonB" <7432D63DBB01D03A196B1EDD80E8@comcast.net> schreef in bericht
news:aj9kpb$41t$1@news.codecharge.com...
> I think I've gotten it squared away. To minimize the impact on this
group,
> I've only posted my event module EditableGrid_Event.php:
> There are several "echo" lines in there to help visualize what's
happening.
> You'll want to take them out.
>
> One BIG note: Convert the ASP version, by changing the project from "ASP"
> to PHP with templates". THEN BE SURE TO CHANGE THE HTML FILE so the
<FORM>
> tag refers to the .php file - it will remain .asp until you change it by
> hand. That is what was hosing me up - I finally realized submitting the
php
> page was submitting it to the asp page! Not very cool, but very confusing
> (the "live" window does not show the URL, so it was easy to miss this).
>
> Don Anderson also pointed me to the use of GetValue and SetValue. Thank!
>
> Don
>
> Don't save the following as your event file. Open your project, go to
your
> EditableGrid.php and add three events: (1) BeforeShow on the label
"price",
> (2) BeforeShow on the checkbox, and (3) AfterInitialize on the grid
itself.
>
> Then paste my corresponding code into your event routines (this will keep
> the "markers" correct (those things that start with "@")
>
> There are two things that need improving upon: (1) ensuring the grid obeys
> security for update/delete actions and (2) I think I'd put hidden
checkboxes
> on the grid, then add client-side code to set these to "ON" when the price
> is changed, This way, only the rows that need updating could be updated -
> by seeing if the checkbox is indeed checked. The original version merely
> updates every row everytime you submit. Not efficient!
>
> don
>
>
> function bs_items_price_BeforeShow() { //bs_items_price_BeforeShow
> @23-21B16B84
>
> //Custom Code @27-2A29BDB7
> // -------------------------
> global $bs_items;
> $bs_items->price->SetValue("<input type=textbox name='" .
> $bs_items->item_id->GetValue() . "' value='" . $bs_items->price->Value .
"'
> size=8>");
> // -------------------------
> //End Custom Code
>
> } //Close bs_items_price_BeforeShow @23-FCB6E20C
>
> function bs_items_to_be_deleted_BeforeShow() {
> //bs_items_to_be_deleted_BeforeShow @25-EED1ED5A
>
> //Custom Code @28-2A29BDB7
> // -------------------------
> global $bs_items;
> $bs_items->to_be_deleted->SetValue("<input type=checkbox name=del." .
> $bs_items->item_id->GetValue() . " value=OFF>");
> // -------------------------
> //End Custom Code
>
> } //Close bs_items_to_be_deleted_BeforeShow @25-FCB6E20C
>
> function Page_AfterInitialize() { //Page_AfterInitialize @1-56434BCA
>
> //Custom Code @33-2A29BDB7
> // -------------------------
> global $bs_items;
> global $DBinternet;
>
> global $QUERY_STRING;
> if (isset($QUERY_STRING)) {
> echo ">>" . $_SERVER['QUERY_STRING'] . "<br>";
> }
> else {
> echo "<< Not Set<br>";
> }
> if (isset($QUERY_STRING)) {
> $qstring = explode("&", $QUERY_STRING);
> foreach ($qstring as $arr => $id) {
> // echo "id$=" . $id . "<br>";
> $itemN = explode("=",$id);
> echo "[0]=" . $itemN[0] . ", [1]=" . $itemN[1] . "<br>";
> if (isset($itemN[1]) and isset($itemN[1])) {
> if ( is_numeric($itemN[0]) and
> is_numeric($itemN[1]) ) {
> // Do an UPDATE of this item
> $strUpdate = "UPDATE bs_items SET price=" . $itemN[1] . " WHERE
item_id
> = " . $itemN[0];
> $DBinternet->query($strUpdate);
> echo $strUpdate . "<br>";
> }
> elseif (strpos($itemN[0],".") > 0){
> // Do a DELETE
> echo "DELETE " . $itemN[0] . "<br>";
> $itemN[0] = str_replace("del.","",$itemN[0]); // Extract just the item
> number (e.g. extract "123" from "del.123");
> $DBinternet->query("DELETE FROM bs_items where item_id=" . $itemN[0]);
> }
> }
>
> } //foreach
> } // if isset
> // -------------------------
> //End Custom Code
>
> } //Close Page_AfterInitialize @1-FCB6E20C
>
> ?>
>
>
>


   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.