This article introduces the implementation code for batch operations of php drop-down options. If you need it, refer to it.
This article introduces the implementation code for batch operations of php drop-down options. If you need it, refer to it.
Implement functions. Operation items can be deleted separately. Batch items can be deleted in batches, displayed in batches, and hidden (the status_is value of the AD database );
1. View key points:
The Code is as follows:
Id?>
The Code is as follows:
Select All
Select Operation Delete Display Hide
The Code is as follows:
/* Single Delete */
CreateUrl ('batch', array ('command' => 'addelete', 'id' => $ row-> id)?> ">
2. Controller:
The Code is as follows:
/**
* Batch operation
*
*/
Public function actionBatch ()
{
If (XUtils: method () = 'get') {// a single Delete is a GET method.
$ Command = trim ($ _ GET ['command']);
$ Ids = intval ($ _ GET ['id']);
} Else
If (XUtils: method () = 'post '){
$ Command = trim ($ _ POST ['command']);
$ Ids = $ _ POST ['id'];
Is_array ($ ids) & $ ids = implode (',', $ ids );
} Else {
XUtils: message ('errorback', 'only POST, GET data ');
}
Empty ($ ids) & XUtils: message ('error', 'no record selected ');
Switch ($ command ){
Case 'addelete ':
Parent: _ acl ('ad _ delete ');
Parent: _ adminiLogger (array ('catalog '=> 'delete', 'intro' => 'delete AD, ID:'. $ ids ));
Parent: _ delete (new Ad (), $ ids, array ('ad'), array ('Attach _ file '));
Break;
Case 'adverify ':
Parent: _ acl ('ad _ verify ');
Parent: _ adminiLogger (array ('catalog '=> 'delete', 'intro' =>'. The ad status changes to display, ID: '. $ ids ));
Parent: _ verify (new Ad (), 'verify ', $ ids, array ('ad '));
Break;
Case 'adunverify ':
Parent: _ acl ('ad _ verify ');
Parent: _ adminiLogger (array ('catalog '=> 'delete', 'intro' =>'. The ad status changes to hidden, ID: '. $ ids ));
Parent: _ verify (new Ad (), 'unverify ', $ ids, array ('ad '));
Break;
Default:
Throw new CHttpException (404, 'wrong operation type: '. $ command );
Break;
}
}
The deletion function of the parent class:
The Code is as follows: