update grild columns

Questionsupdate grild columns
mohammad shahid asked 3 years ago

am trying to raise an invoice from a master/detail grind. I have 2 questions.
 1.  In the details grid we need to find price of the product based on selection of product from productid grid.  product dropdown has key value pair which is productid and productname from product table. Now how do we show price in price field whenever product is selected?
2. In the details grid, we calculate amount by price+quantity and we have a footer field total amount which is working fine. Now we need to update the amount field of the master with this total amount. As is norm with any invoice, all rows have qty**price as amount and a total amount at the footer. Now we need to update the amount field in master with this total amount. How do we do that?

4 Answers
Abu Ghufran Staff answered 3 years ago

Please share screenshot / related grid code explaining your query.

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
mohammad shahid answered 3 years ago

WE need to update price based on selection of the product.

$col = array();
$col[“title”] = “Product”;
$col[“name”] = “productid”;
$col[“dbname”] = “invoicedetails.productid”; // this is required as we need to search in name field, not id
$col[“width”] = “180”;
$col[“align”] = “left”;
$col[“search”] = true;
$col[“editable”] = true;
$col[“edittype”] = “select”; // render as select
# fetch data from database, with alias k for key, v for value
$str = $grid->get_dropdown_values(“select productid as k, productname as v from product “);
$col[“editoptions”] = array(“value”=>”:;”.$str);

$col[“editoptions”][“onload”][“sql”] = “select productid as k, productname as v from product WHERE subcategoryid = ‘{subcatid}'”;
$col[“formatter”] = “select”; // display label, not value
$cols[] = $col;

$col = array();
$col[“title”] = “Price”;
$col[“name”] = “price”;
$col[“width”] = “100”;
$col[“editable”] = true;
$col[“editrules”] = array(“required”=>True);
//$col[“hidden”] = true;
$cols[] = $col;

mohammad shahid answered 3 years ago

Secondly we need to update the amount field in master grid from running total of footer total.

Abu Ghufran Staff answered 3 years ago

For your first query, you can review this code:

https://www.gridphp.com/demo/demos/appearance/dropdown-callback.phps

Lines:
62-67
122-129

For your second query, please send your query with screenshot for better understanding. Currently it’s not very clear. Most likely you will need custom JS code to read via jquery and fill in desired field.

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Your Answer

11 + 12 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?