Maybe a clear way?
Maybe a clear way?
alexandremarques
Posts: 8Questions: 0Answers: 0
Could anyone help me, how can I can accomplish this task with not-that-omg-many lines of code?
Task is simple: fill a data table and put a button on it's last column to "see more results":
$('#DadoCivil_PRG_Listagem').dataTable({
"bRetrieve": true,
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"bProcessing": true,
"sAjaxSource": 'index.php?modulo=Pessoa-PessoaDadoCivil&action=CarregarListaPessoaRG',
"fnServerData": function ( sSource, aoData, fnCallback ) {
$.ajax( {
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": {
"args": [ $('#PES_IDPESSOA').val() ]
},
"success": fnCallback
} )
},
"aoColumns": [
null,
null,
null,
null,
null,
{
"bSortable": false
}
],
"aaSorting": [[ 1, "asc" ]],
"fnDrawCallback": function () {
$("#DadoCivil_PRG_Listagem tbody tr").each(function(){
var value = $(this).children().eq(5).children().attr("id");
if (value == undefined) {
value = $(this).children().eq(5).text();
var html = ' ';
$(this).children().eq(5).html(html);
$(this).children().eq(5).children().click(function() {
$.getJSON(
"index.php?modulo=Pessoa-PessoaDadoCivil&action=ExibirCadastroRG",
{
args:[$(this).val()]
},
function(data) {
$('#DadoCivil_PRG_IDPESSOARG').val(data.PRG_IDPESSOARG);
$('#DadoCivil_PRG_NUPESSOARG').val(data.PRG_NUPESSOARG);
$('#DadoCivil_PRG_OEP_IDORGAOEXPEDIDOR').val(data.OEP_IDORGAOEXPEDIDOR);
$('#DadoCivil_PRG_OEP_IDORGAOEXPEDIDOR-combo').val($("#DadoCivil_PRG_OEP_IDORGAOEXPEDIDOR option[value='"+ data.OEP_IDORGAOEXPEDIDOR +"']").text());
$('#DadoCivil_PRG_DTEXPEDICAO').val(data.PRG_DTEXPEDICAO);
$('#DadoCivil_PRG_MUN_IDMUNICIPIO').val(data.MUN_IDMUNICIPIO);
$('#DadoCivil_PRG_MUN_DLMUNICIPIO').val(data.MUN_DLMUNICIPIO);
$('#DadoCivil_PRG_MUN_UF_CDUF').val(data.UF_CDUF);
}
);
})
.button({
icons: {
primary: 'ui-icon-check'
},
text: false
});
}
$(this).mouseover(function(){
$(this).addClass("ui-state-hover");
}).mouseout(function(){
$(this).removeClass("ui-state-hover");
});
});
}
});
$('#DadoCivil_PRG_Listagem_s').combobox();
Task is simple: fill a data table and put a button on it's last column to "see more results":
$('#DadoCivil_PRG_Listagem').dataTable({
"bRetrieve": true,
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"bProcessing": true,
"sAjaxSource": 'index.php?modulo=Pessoa-PessoaDadoCivil&action=CarregarListaPessoaRG',
"fnServerData": function ( sSource, aoData, fnCallback ) {
$.ajax( {
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": {
"args": [ $('#PES_IDPESSOA').val() ]
},
"success": fnCallback
} )
},
"aoColumns": [
null,
null,
null,
null,
null,
{
"bSortable": false
}
],
"aaSorting": [[ 1, "asc" ]],
"fnDrawCallback": function () {
$("#DadoCivil_PRG_Listagem tbody tr").each(function(){
var value = $(this).children().eq(5).children().attr("id");
if (value == undefined) {
value = $(this).children().eq(5).text();
var html = ' ';
$(this).children().eq(5).html(html);
$(this).children().eq(5).children().click(function() {
$.getJSON(
"index.php?modulo=Pessoa-PessoaDadoCivil&action=ExibirCadastroRG",
{
args:[$(this).val()]
},
function(data) {
$('#DadoCivil_PRG_IDPESSOARG').val(data.PRG_IDPESSOARG);
$('#DadoCivil_PRG_NUPESSOARG').val(data.PRG_NUPESSOARG);
$('#DadoCivil_PRG_OEP_IDORGAOEXPEDIDOR').val(data.OEP_IDORGAOEXPEDIDOR);
$('#DadoCivil_PRG_OEP_IDORGAOEXPEDIDOR-combo').val($("#DadoCivil_PRG_OEP_IDORGAOEXPEDIDOR option[value='"+ data.OEP_IDORGAOEXPEDIDOR +"']").text());
$('#DadoCivil_PRG_DTEXPEDICAO').val(data.PRG_DTEXPEDICAO);
$('#DadoCivil_PRG_MUN_IDMUNICIPIO').val(data.MUN_IDMUNICIPIO);
$('#DadoCivil_PRG_MUN_DLMUNICIPIO').val(data.MUN_DLMUNICIPIO);
$('#DadoCivil_PRG_MUN_UF_CDUF').val(data.UF_CDUF);
}
);
})
.button({
icons: {
primary: 'ui-icon-check'
},
text: false
});
}
$(this).mouseover(function(){
$(this).addClass("ui-state-hover");
}).mouseout(function(){
$(this).removeClass("ui-state-hover");
});
});
}
});
$('#DadoCivil_PRG_Listagem_s').combobox();
This discussion has been closed.