Ext4.2gird 대량 삭제, 마지막 페이지 전체 삭제 조회 이전 페이지

3540 단어 삭제extgrid
// 
function getPageList(pageIndex){
	if(typeof(pageIndex) == "undefined"){
		pageIndex = 1;
	}
	//stoOrganization.currentPage=1; // (pagingtoolbar) 
	stoOrganization.pageSize = pagesize_combo.getValue();
	//stoOrganization.load({params: { start: 0, limit: pagesize_combo.getValue() }});
	stoOrganization.loadPage(pageIndex,{params: { start: (pageIndex-1)*stoOrganization.pageSize, limit: pagesize_combo.getValue()}});
}

  
// 
function remove(){
	gridRemove(gridOrganization,stoOrganization,'id','remove.json','POST',function(response, opts, pageIndex){
		refreshNode(treOrganization, false, currentNodeId, parentNodeId);
		getPageList(pageIndex);
		gridOrganization.getSelectionModel().deselectAll();
	});
}

 
/**
 *  grid ids
 * @param records	 
 * @param id		id 
 * @returns			1,2,3
 */
function getIds(records,id){
	var ids = [];
	for (var i = 0; i < records.length; i++) {
		ids.push(records[i].get(id));
	}
	return ids.toString();
}

 
/**
 *  
 * @param grid		grid 
 * @param store		sotre 
 * @param id		id 
 * @param url		 url
 * @param method	 GET/POST
 */
function gridRemove(grid,store,id,url,method,callback){

	//var pageCount = grid.getDockedItems('toolbar[dock="bottom"]')[0].getPageData().pageCount;

	var isLastPage = false;	// 
    if(!(store.last()) || store.indexOfTotal(store.last()) == store.getTotalCount()-1){
    	isLastPage = true;
    }

	var records = grid.getSelectionModel().getSelection();
	if(records.length == 0){
		Ext.Msg.alert(" ", " !");
		return;
	}
	
	var ids = getIds(records, id);
	
    Ext.Msg.confirm(" ", " ?", function (button) {
        if (button == "yes") {
            Ext.Ajax.request({
        	    url: url,
        	    method: method,
        	    params: {
        	        ids: ids
        	    },
        	    success: function(response, opts) {
        	        var json = Ext.decode(response.responseText);
        	        if(json.status == "success"){
        	        	//store.reload();
        	        	Ext.Msg.alert(' ', " !");
        	        	
        	        	// , , 
        	        	if(isLastPage && store.getCount() == records.length){
        	        		if(store.currentPage > 1){
        	        			store.currentPage = store.currentPage - 1;
        	        		}
        	        	}
        	        	
        	        	if(typeof(callback) == 'function'){
        	        		callback(response, opts, store.currentPage);
        	        	} else {
        	        		store.reload();
        	        	}
        	        } else {
        	        	Ext.Msg.alert(' ', json.msg);
        	        }
        	        
        	    },
        	    failure: function(response, opts) {
        	    	Ext.Msg.alert(' ', ' !'); //response.status
        	    }
            });
        }
    });
}

좋은 웹페이지 즐겨찾기