The delete function doesn't know the primary key

QuestionsThe delete function doesn't know the primary key
Massimo Gagliardi asked 11 years ago

The delete function does not know the primary key.
This is the primary key definition, made ​​so as to be invisible in the grid, but enabled in the edit / add form:

$col = array();
$col["title"] = "ID";
$col["name"] = "IDClienteFornitore";
$col["width"] = "5";
$col["hidden"] = true;
$col["editable"] = true;
$col["editrules"] = array("edithidden"=>false); $col["align"] = "right"; $col["export"] = $grantcol;
$cols[] = $col;

this is the custom update SQL:

UPDATE hmr_own_clienti_fornitori SET … WHERE IDClienteFornitore = {$data["params"]["IDClienteFornitore"]} AND IDAzienda = " . $IDAzienda
this works!

this is the custom delete SQL:

DELETE FROM hmr_own_clienti_fornitori WHERE IDClienteFornitore = {$data["params"]["IDClienteFornitore"]} AND IDAzienda = " . $IDAzienda;
this doesn't work!

Why?

Thanks in advance
Regards
Massimo Gagliardi

5 Answers
Abu Ghufran answered 11 years ago

The ID can be accessed by $data["IDClienteFornitore"].

Reference: demos/editing/custom-events.php
function delete_client($data)
{
print_r($data);
/*
These comments are just to show the input param format
$data => Array
(
[client_id] => 2
)
*/
}

Massimo Gagliardi answered 11 years ago

I understand but there isn't a possibility to use the default deleting function without a custom function?

Massimo Gagliardi answered 11 years ago

An append to my last:
$data["IDClienteFornitore"] shows the number row of the grid not the field's content; consequence isn't valid to delete a record

Abu Ghufran answered 11 years ago

You just need to comment on_delete event in grid config. After that it will work with normal delete.

I emailed you a fix for row-number & id issue

Massimo Gagliardi answered 11 years ago

Thank you very much
It works with both a delete custom function as without.

Your Answer

2 + 7 =

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?