on_clone custom function error

Questionson_clone custom function error
Jorge asked 10 years ago

Hi! I have written on_clone custom function for test that works, but shows error "200: OK. Status: parsererror":


$e["on_clone"] = array("clone_row","",false);

function clone_row($data)
{
mysql_query("INSERT INTO test_table (Name) VALUES ('TEST')");
}

I used "null", "" and null values on array, but the result is the same.

I have licensed version.

Can you help me?

Thank you!

4 Answers
Abu Ghufran answered 10 years ago

There is a fix required in core lib (lib/inc/jqgrid_dist.php)
In 'fx_clone_row = function (grid,id)' … change datetype from 'json' to 'html'

fx_clone_row = function (grid,id)
{
myData = {};
myData.id = id;
myData.grid_id = grid;
myData.oper = 'clone';
jQuery.ajax({
url: "<?php echo $this->options["url"]?>",
dataType: "html", // <<<<<<<<<<<———————————————–
data: myData,
type: "POST",

Jorge answered 10 years ago

Fix works perfectly. Thank you!

Jorge answered 10 years ago

Sorry for reopening the issue, but if I use on_clone function this way, it seems that params data not work. Removing the fix does not work either.


$e["on_clone"] = array("clone", "null", true);

function clone($data)
{
$data["params"]["Name"] = "TEST";
}

Abu Ghufran answered 10 years ago

The on_clone event don't have such param that allow changing data.
e.g. data content are:

Array
(
[id] => 14
[params] => Array
(
[0] => invdate
[1] => client_id
[2] => amount
[3] => tax
[4] => total
[5] => note
[6] => closed
[7] => ship_via
)
)

id: the row id (pk) being copied
params: all the fields that will be copied.

If you wish to change the data, you can run another select query to fetch data of row id, and run custom insert.
If you don't wish to run default clone insert query, and write your own logic, you can put 3rd argument to false.
$e["on_clone"] = array("clone", null, false);

Your Answer

11 + 0 =

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?