Sir,
My users add a record and status is set to 'ADD'.
Users are not allowed to edit a record when the status field = 'ADD', but otherwise, I would like to use the on_update callback.
I can check for the status in the callback function – can I then abort the automatic Edit?
Thanks in advance
Hello,
This is doable with server side validation.
You can put this check in on_update.
Refer demos/editing/server-validation.php code sample.
Thanks, Abu,
The sample you cite does not use true as the third argument. I do:
$e["on_update"] = array("update_customer", null, true);
In the function update_customer(), I discover that I must not allow the edit to proceed. Can I then cancel the edit?
I am trying to use phpGrid to do the Update in most (almost all) cases, and stop it only sometimes…
Hi,
In function when you call, phpgrid_error()
e.g.
phpgrid_error("Client already exist in database");
Then it stops execution and show message on grid.
Hi,
By default grid assumes that first column is auto-generated (hence auto-inserted on insert query)
If you want to insert it from grid, you can set with listId:
$col["autoid"] = false;
Abu,
Using this same technique, I call $e["on_insert"] = array("addCustomer", null, true);
In addCustomer(), I update a lot of default column values, and I assign a random value to ListID, which is my table key and the first column in my Select. (only operating on 1 table)
***ListID is never inserted in the table.***
This is what my array looks like as I exit addCustomer and have phpGrid continue the row addition:
13-Apr-2017 20:46:55 Europe/Berlin] Array
(
[ListID] => 764809223
[params] => Array
(
[FullName] => BDA Test4
[Contact] => pat
[Phone] => 0987654321
[Email] =>
[ShipAddress_Addr2] =>
[ShipAddress_Addr3] =>
[ShipAddress_City] =>
[ShipAddress_State] =>
[ShipAddress_PostalCode] =>
[Status] => ADD
[Name] => BDA Test4
[AccountNumber] => 493629115
[SalesRepRef_FullName] => joe staff
[CustomerTypeRef_FullName] => CREDITHOLD
[TermsRef_FullName] => Net 30
[isActive] => true
[CustomField1] => 0%
)
)
Any ideas?
The definition of column ListID is:
$col = array();
$col["title"] = "ListID";
$col["name"] = "ListID";
$col["show"] = array("list"=>false,"add"=>false, "edit"=>false, "view"=>false);
$col["editable"] = true;
$col["export"] = false;
$cols[] = $col;
Thanks, Abu: this works!
Now I have a few other issues wrt to errors:
1. php_error_log shows: PHP Notice: Undefined index: xyz for all of the columns I am adding.
2. If I simply refresh my grid I see: PHP Warning: Invalid argument supplied for foreach() in C:xampphtdocsbecustomfileslibincjqgrid_dist.php on line 5527
There are no errors/warnings when I edit a column.
I realize one can turn reporting off, but not sure that is a good approach.
Thanks in advance.
About notices, so far (turning off reporting) that's the solution we use. And optimization is in our todos.
Regarding warning, if you can send exact line or email me whole jqgrid_dist.php … i can check. It should not be displayed.