Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - mjg77025

Pages: [1]
1
Help for ParamQuery Pro / Re: Passing Variable to Grid
« on: February 10, 2015, 10:58:56 pm »
My issue does relate to the grid as it involves getting the proper data to appear in the grid.   Let me see if I can explain this a little better.

There are three files
receiverdetail.php                  This file is my application file and where the grid is called in a div.   This file also contains a variable $dsd_combo_key
receiverdetailgrid.php             This file is the .php file for the grid and is called by receiverdetailgrid.js
receiverdetailgrid.js                This is the javascript file for the grid


The variable $dsd_combo_key is a combination of two variables $dsd_vendor and $dsd_vendor_invoice_number.  This number is created from a form that calls receiverdetail.php upon submit. In order to make sure the grid is pulling the right information I need to be able to query the database and pull only items with the correct $dsd_combo_key in the grid on the receiverdetail.php.

Here is my dilemma... receiverdetail.php has both the variable and the code for the div.   When the div is called it then executes receiverdetailgrid.js which calls receiverdetailgrid.php and executes SQL depending on whether the action is select, insert, or delete.   On the select in receiverdetailgrid.php I need to be able to give that SQL statement a where   ( where dsd_detail_combo_key='$dsd_combo_key') that uses the variable from the initial page that contains the div.  That Where clause will only display information that has the same $dsd_combo_key.

So my question is how would I get that data to the grid?   I'm sure there are other people out there that would like to use the grid dynamically depending on data from a form to create the grid.  But I can't seem to understand how to pass that variable from .php to .js to .php so that I can get the proper variable data for my select statement.

2
Help for ParamQuery Pro / Re: Passing Variable to Grid
« on: February 10, 2015, 09:55:03 am »
I need it as part of my SQL query that pulls certain data from the database.

 $sql = "Select dsd_detail_id, dsd_detail_combo_key, dsd_detail_item, dsd_detail_item_units,
        dsd_detail_item_cases, dsd_detail_item_case_cost, dsd_detail_item_unit_cost, dsd_detail_item_allowance_one,
        dsd_detail_item_allowance_two from dsd_detail where dsd_detail_combo_key='$dsd_combo_key'";
        $dbh = new PDO("pgsql:host=localhost;dbname=fredhost","xxxx123","xxxx179");
        $stmt = $dbh->prepare($sql);
        $stmt->execute();
        $rows = $stmt->fetchAll(PDO::FETCH_ASSOC);

However, since the .js file is calling the .php file that does the select the problem is getting the data from the main page and then to either the .js or .php files for building the grid.

Any thoughts?

3
Help for ParamQuery Pro / Re: Passing Variable to Grid
« on: February 06, 2015, 12:18:31 pm »
I have that setup in colModel already.   Here is a little better explanation of what I'm trying to do.


In my PHP file that is for my application I call the datagrid JS file and then call the grid in my php file using this:


<div class="tabContent" id="receiverdetail" >
       <div id="dsdreceiverdetailgrid" >
       </div>
</div>

The variable is created in my PHP file for my application before I call the grid.

so....

$retail_grid_combo key=$vendor.$invoice.$invoice_date;

This variable is directly before the <div> to call the grid into my application page.

How would I pass that variable into the php file that inserts the data from the grid?   Or would I need to pass the variable to the javascript file first?

Thanks!

4
Help for ParamQuery Pro / Passing Variable to Grid
« on: February 04, 2015, 11:47:56 pm »
I need to pass a variable from my application's PHP code to a grid.   The javascript is an include in my main PHP file and the grid is called using the standard method.

Example:

We have a grid that stores items for a customer's order invoice.   The Primary PHP has all of the customer and invoice fields at the top of the page and the grid for items underneath.
Primary PHP script generates a variable that needs to be passed to a field (lets call this field CustomerInvoiceKey) in the grid for each new row.   This variable is generated from user input from a previous form page and is unique to the user and invoice that is being proccessed.

How would I pass that variable to the grid so that it shows up in the proper field on each line in the grid?

5
Got it!   Removed all of the excess session and array code and made it work for all three!  Thanks!

Example:

else if( isset($_GET["pq_delete"]))   
{
    session_start();
    $productid = $_GET["productid"];
   
    $sqldel = "delete from products where productid='$productid'";
   $conndel = new PDO("pgsql:host=localhost;dbname=fredhost","xxxx","xxxx");
    $stmtdel = $conndel->prepare($sqldel);
   $stmtdel->execute();
     
    echo "{\"result\": \"success\"}";
    $conndel = null;
}   

6
The changes do persist in the database.   If I refresh the page the changes show.

How would I put a break point or alert in the callback?

Here is my code for the delete function...

else if( isset($_GET["pq_delete"]))   
{
    session_start();
    $productid = $_GET["productid"];
    $products = json_decode($_SESSION["products"], true);   
    foreach($products as $i => $product){
        if($product["productid"] == $productid){           
            unset($products[$i]);
        }       
    }
   
    $sqldel = "delete from products where productid='$productid'";
   $conndel = new PDO("pgsql:host=localhost;dbname=xxxxx","xxxxx","xxxxx");
    $stmtdel = $conndel->prepare($sqldel);
   $stmtdel->execute();
   
    $_SESSION["products"]= json_encode($products);   
    echo "{\"result\": \"success\"}";
    $conndel = null;
}   

7
Thanks for the info.

I managed to get add, delete, and update to work however the page does not refresh after the operation.

What am I missing?

8
Help for ParamQuery Pro / SQL Insert / Update / Delete for Inline Grid
« on: January 07, 2015, 02:43:00 am »
Does anyone have any code examples for inserting / updating / deleting records in SQL for the Inline Editing Grid?

Thanks!

9
Help for ParamQuery Pro / Re: Inline Editing Example and Postgres
« on: January 02, 2015, 05:31:24 pm »
Awesome!   Got it fixed!

I had deleted a character from the url in the javascript and that was causing my issues.

Are there any SQL examples available for the Update, Delete, and Edit functions?

10
Help for ParamQuery Pro / Re: Inline Editing Example and Postgres
« on: January 02, 2015, 02:39:38 pm »
I got the test script to output data and now after I have corrected my PDO I get this:

{"data":[{"ProductID":1,"ProductName":"test","QuantityPerUnit":1,"UnitPrice":1,"UnitsInStock":1,"Discontinued":"true"},{"ProductID":2,"ProductName":"test2 ","QuantityPerUnit":1,"UnitPrice":2,"UnitsInStock":3,"Discontinued":"false"}]}

Followed by an empty grid.

Any thoughts?

11
Help for ParamQuery Pro / Inline Editing Example and Postgres
« on: December 31, 2014, 01:04:59 am »
I am attempting the inline row editing example on the demos page and I'm getting the following response

{"data":[]}  followed by an empty grid.

The only code I have changed is in the PDO portion of the PHP code and the relevant PHP portions in the JS

Here is what I have changed in the PHP:

    if (isset($_SESSION["Products"])==false)
    {
        //add in session["Products"];
        $sql = "Select ProductID, ProductName, QuantityPerUnit, UnitPrice, UnitsInStock, Discontinued from products";
        $dbh = new PDO("pgsql:host=localhost;dbname=fredhost;user=control;password=remotexxx;port=5432");
        $stmt = $dbh->prepare($sql);
        $stmt->execute();
        $rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
 
        $_SESSION["Products"]= json_encode($rows);
    }   

Any reason why I am not getting any data?

Pages: [1]