Created
September 6, 2016 12:07
-
-
Save vlademiro/41eb57cf61f4cc462fb951f56b5d76ee to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Created by vlad on 06/09/2016. | |
*/ | |
//IniBlock=downloadXLS | |
//Automatic=Yes | |
function downloadXLS( url ){ | |
//var url = "/dc/Brw_usuario/downloadXLS/"; | |
var postData = { | |
}; | |
// begin | |
$.ajax({ | |
type: "POST", | |
// url para o arquivo json.php | |
url : url, | |
// dataType json | |
dataType : "json", | |
data: postData, | |
error: function(msg) { | |
alert("Erro de conexão. Verifique se a Internet está ok."); | |
//need to traverse to success and if false, do something | |
} | |
});//end ajax | |
} | |
//EndBlock | |
//downloadXLS (END) | |
//IniBlock=RefreshGrid | |
//Automatic=Yes | |
function refreshGrid( skip , key_mother){ | |
/** | |
* Inicialmente os botões next e previous | |
* devem estar desabilitados | |
*/ | |
var url = "/dc/Brw_usuario/listjson/?page=" + $("#page").val() + "&skip=" + skip; | |
//alert( url ); | |
var postData = { | |
}; | |
// begin | |
$.ajax({ | |
type: "POST", | |
// url para o arquivo json.php | |
url : url, | |
// dataType json | |
dataType : "json", | |
data: postData, | |
success : function(data){ | |
var row; | |
$("#gridBody").empty(); | |
if ( data.status == "OK" ){ | |
if ( data.nextPage == "true" ){ | |
$("#nextPage").show(); | |
} else { | |
$("#nextPage").hide(); | |
} | |
if ( data.previousPage == "true" ){ | |
$("#previousPage").show(); | |
} else { | |
$("#previousPage").hide(); | |
} | |
$("#page").val( data.page ); | |
key = []; /* Array global (Primary keys) */ | |
for( i=0; i < data.dados.length; i++){ | |
row = "<tr class='rowGrid' id=" + i + ">"; | |
data.dados[i]['login'] = data.dados[i]['login'] == null ? "" : data.dados[i]['login']; | |
row += ("<td>" + data.dados[i]['login'] + "</td>"); | |
data.dados[i]['grupo'] = data.dados[i]['grupo'] == null ? "" : data.dados[i]['grupo']; | |
row += ("<td>" + data.dados[i]['grupo'] + "</td>"); | |
row += "<td class='actions'>"; | |
row += " <a class='btn btn-success btn-xs edt-frm_usuario' data-toggle='modal' href='#'>Editar</a>"; | |
row += " <a class='btn btn-danger btn-xs del-frm_usuario' data-toggle='modal' href='#'>Excluir</a>"; | |
row += "</td>"; | |
row += "<tr>"; | |
$("#gridBody").append(row); | |
// | |
key.push( data.dados[i].id_usuario ); /* Array global (primary keys for edition) */ | |
}//end loop for | |
} else { | |
$("#nextPage").hide(); | |
$("#previousPage").hide(); | |
row = "<tr class='rowGrid'><td><b>A consulta não retornou dados</b></td></tr>"; | |
$("#gridBody").append(row); | |
} | |
}, | |
error: function(msg) { | |
alert("Erro de conexão. Verifique se a Internet está ok."); | |
} | |
});//end ajax | |
} | |
//EndBlock | |
//RefreshGrid (END) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment