Call function using setTimeout

QuestionsCall function using setTimeout
C3media asked 8 years ago

Hello,

It´s possible execute a Function based in setTimeout Jquery?

5 Answers
Abu Ghufran answered 8 years ago

Hi,

Your question is unclear. Please show code/screenshot.

C3media answered 8 years ago

Abu this is my code:

function update_data($data)
{
//phpgrid_error($data);
// you can also use grid object to execute sql, useful in non-mysql driver

// global $grid;
// $grid->execute_query("MY-SQL");
date_default_timezone_set('America/Bogota');
$date1 = date("Y-m-d H:i:s"); // This is Llegada Col
$date2 = $data["params"]["note"]; //This is Salida Col
// phpgrid_error($data);
//Convert them to timestamps.
$date1Timestamp = strtotime($date1);
$date2Timestamp = strtotime($date2);

//Calculate the difference.
$difference = ($date1Timestamp – $date2Timestamp)/60;
$diferencia= number_format($difference, 0, '.', ',');

$data["params"]["staff_note"] = $date1;

$data["params"]["due_date"] = $diferencia;

$data["params"]["shipping"] = $data["params"]["shipping"];

$data["params"]["total"] = $data["params"]["total"];

/*
if
(($data["params"]["due_date"]) >= ($data["params"]["reference_no"])){
$data["params"]["updated_by"] = (($data["params"]["due_date"]) – ($data["params"]["reference_no"]));
}
else
{
$data["params"]["updated_by"] = 0;
}
endif;
*/
//Recobro = excedió x 500

$data["params"]["attachment"] = $data["params"]["attachment"];

$data["params"]["paid"] = $data["params"]["total"];

$data["params"]["updated_at"] = $data["params"]["updated_by"] * (500);

//subtotal = Recobro
//$data["params"]["total_discount"] = $data["params"]["updated_at"];
//total = precio – descuento
//total = total + subtotal
//$data["params"]["total"] = $data["params"]["total"] + $data["params"]["total_discount"]

$data["params"]["grand_total"] = $data["params"]["updated_at"];

$data["params"]["total"] = $data["params"]["grand_total"] + $data["params"]["paid"];

$data["params"]["sale_status"] = "Completed";

$data["params"]["total_tax"] = 0;

}

This is executing on_update method, so I need be working on_after_insert but using setTimeOut to update each minute for example.

Thank you!

Abu Ghufran answered 8 years ago

Are you implementing something like Autosave function?
Please tell exact scenario so i can suggest better.
Screenshot would help.

C3media answered 8 years ago

Hello Abu,

Share you screenshot:

https://yadi.sk/i/m2lBhAKh3GjWmg

Thanks!

Abu Ghufran answered 8 years ago

Currently this is not supported by grid.

If you know the row id, you can set it using
var grid = $("#list1");
grid.jqGrid('setCell',id,'price','2000');

where list1 is gridid, price is column name, 2000 is value to set in cell.

I think i still don't understand your question. Please explain more if not resolved.

Your Answer

17 + 17 =

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?