In the development process, we may often encounter the need to delete records in batches. If we are using easyUI+struts2, let's see how we do it. Although the problem is relatively small, it is sometimes quite annoying.
- // delete
- function batchDelete() {
- var checks = $('#firmresult').datagrid('getChecked');
- if(checks.length==0){
- $.messager.alert( 'Prompt' , 'Please select the record to delete.' , 'warning' );
- }else{
- $.messager.confirm( 'Prompt' , 'Are you sure you want to delete these records?' , function (r){
- if (r){
- var firmIds = [];
- for (var i = 0; i < checks.length; i++) {
- var id = checks[i]['userId'];
- firmIds.push(id);
- }
- var userType = $("#userType").combobox('getValue');
- var params =
- 'firmQueryBean.userIds':firmIds,'firmQueryBean.userType':userType
- };
- //If the parameter contains an array, you must serialize the parameter before the background can receive it
- var ps = $.param(params, true ); //This is the key, we serialize the parameters and then pass them to the background, otherwise the background will never receive the data we pass
- $.post("deleteFirmInfos.action", ps,
- function(data){
- if(data && data.suc){
- $.messager.alert( 'Prompt' , 'Deletion successful!' , 'info' , function (){
- subSerach();
- });
- }else{
- $.messager.alert( 'Prompt' , 'Deletion failed.' , 'error' );
- }
- }, "json");
- }
- });
- }
- }
Well, without further ado, just a little bit of attention. Happy IT friends!