Fetching data while adding a record

QuestionsFetching data while adding a record
Alfonso Cabrera asked 9 years ago

Hi Abu!

I would like to know if there is a function can use to fetch data from my database and put it in a column while I'am adding a new record.

Example:

I'm adding a new record I picked a product and I have a Price List that relates the product to his price so I want to pick from the dropdown a product and place in the column Price the price that I found by searching in the Price List while I'am adding the record.

I use the event ["on_insert"] and ["on_update"] for some grids but for this one I want something like ["on_adding"] or ["on_newrecord"]

4 Answers
Abu Ghufran answered 9 years ago

Please refer demos/appearance/dropdown-callback.php
It fills textbox after dropdown selection.

Alfonso Cabrera answered 9 years ago

Thanks Abu, I have just another question.

I'm passing the rowid and the client_id of the master grid to the detail grid. I need to use these 2 values to make a function that searches in my database for the price of the product because I have more than one price list, example: Price List 1, Price List 2 and Price List 3, so each client may only have one price list selected but I have 3 prices of the same product.

$id = intval($_GET["rowid"]);
$client = intval($_GET["idClientes"]);
$idListas_Precios = intval(Carga_Id($client));

Carga_Id is a function that I created to get the Id of the Price List that the client has. The problem is that I only get the values of the rowid and idClientes columns when I use the [on_insert] and [on_update] events. Is there any way to get this values without using these 2 functions.

Dropdown

$str = $g->get_dropdown_values("select idProductos as k, descripcion as v from productos");
$col["editoptions"] = array(
"value"=>$str,
"onchange" => array(
"sql"=>"SELECT precio FROM precios WHERE idListas_Precios = $idListas_Precios",
"search_on"=>"idProductos",
"callback" => "fill_form" )
);

I need to update the price column when I'm adding the record, it is a lot more helpful for the user to know the price of the product when he picks it from the dropdown not when he already add the record. I hope I made my self clear.

Thank you.

Abu Ghufran answered 9 years ago

Hello,

It should work with dropdown and callback function.
Please tell exact issue you are facing in it. Screenshot + complete code would help.

Alfonso Cabrera answered 9 years ago

Hi Abu!

I manage to solve the problem, you helped me in another request to get the ID of the Client from the dropdown autocomplete not the name, so the function wasn't working because I was passing the name insted of the ID.

Thank you.

Your Answer

2 + 11 =

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?