Bulk Edit doesn't work for my table

QuestionsBulk Edit doesn't work for my table
Chisum asked 5 years ago

I turned on debug mode to try to determine why.

mysqli): SELECT * FROM my_table WHERE 1=1 LIMIT 1 OFFSET 0

(mysqli): UPDATE my_table SET `product_id`=”,`warehouse_id`=”,`qty`=’1′,`available_qty`=”,`ship_qty`=”,`room_shelf`=”,`cost`=”,`sale`=”,`backorders`=”,`stock_status`=” WHERE `item_id` IN (”)

{“id”:””,”success”:true}

This is the data sent with the request:

item_id

product_id

warehouse_id

qty
1

available_qty

ship_qty

room_shelf

cost

sale

backorders

stock_status

oper
edit

id
1,2

 

And here is the php setup:

$g = new jqgrid($db_conf);
$g->con->debug = 0;
$g->table = “my_table”;

$opt=[];
$opt[“multiselect”] = true;
$g->set_options($opt);

$g->set_actions(array(
“add”=>true,
“edit”=>true,
“clone”=>true,
“bulkedit”=>true,
“delete”=>true,
“view”=>true,
“rowactions”=>true,
“export”=>true,
“import”=>true,
“autofilter” => true,
“search” => “simple”,
“inlineadd” => true,
“showhidecolumns” => true
)
);

$out = $g->render(“list1”);

 

It seems to send the right ids, but not put them in the IN condition as it should, it also seems like it will wipe out rather than ignore the blank field values which is not good at all.  I saw to attach code via gist but I don’t have a github account and don’t wish for one.

2 Answers
chisum answered 5 years ago

Not an answer but an update, i managed to get it to work with this php code but it’s not ideal since it basically rewrote the entire update process.  I included some basic calcs I need too but ya.  I’d like to not have to write custom update queries for every grid I make and wonder why it doesn’t work out of the box.  Thanks.

$e[“on_update”] = array(“update_client”, null, true);
function update_client(&$data) {
//multiupdate
if(!empty($_REQUEST[‘id’]) && $_REQUEST[‘oper’]==’edit’){
$item_ids = explode(“,”,$_REQUEST[‘id’]);
$params = [];
foreach($_POST as $k=>$v){
if(!empty($v) && $k!=’oper’ && $k!=’id’) $params[$k]=$v;
}
////print_r($params);
$setstr = ”;
foreach($params as $k=>$v){
$setstr.=”$k=’$v’,”;
}
$setstr = rtrim($setstr,”,”);
foreach($item_ids as $item_id){
$row = qone(“select * from my_table where item_id=$item_id”);
if(isset($params[‘qty’])){
$avail_qty = $params[‘qty’] – $row[‘ship_qty’];
$setstr.=”,available_qty=$avail_qty”;
}
qup(“update my_table set $setstr where item_id=$item_id”);
}
//print_r($data);
//die();
}
else {
#$row = qone(“select * from my_table where item_id=$data[item_id]”);
$data[“params”][“available_qty”] = $data[‘params’][‘qty’] – $row[‘ship_qty’];
}
}
$g->set_events($e);

Abu Ghufran Staff answered 5 years ago

I’ve also emailed you latest build that should solve it.

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Your Answer

16 + 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?