Skip to content

Instantly share code, notes, and snippets.

@juareznjunior
Created December 19, 2014 15:50
Show Gist options
  • Save juareznjunior/a682d85f301bf62516ef to your computer and use it in GitHub Desktop.
Save juareznjunior/a682d85f301bf62516ef to your computer and use it in GitHub Desktop.
Dúvida no UI DataGrid
$(function(){
var $dgLocal = $('#data-grid-local')
,$pesqcidade = $("#pesqcidade")
,$pesquf = $("#pesquf");
$dgLocal.datagrid({
autoLoad: false
,pagination: false
,rowNumber: true
,jsonStore: {
url: 'Dados/cidade_json.php'
}
,ajaxMethod: 'post'
,mapper:[{
name: 'cidade',title:'Cidade',width:200,align:'center'
},{
name: 'uf',title:'UF',width:50,align:'left'
}]
,eventController: {
onClickRow: function(tr) {
document.getElementById('cidade').value = tr.cells[1].innerHTML;
document.getElementById('uf').value = tr.cells[2].innerHTML;
}
}
});
$('#btnpesquisa').on('click',function (){
if( $pesqcidade.val() !== "" ){
$dgLocal
.datagrid('addParam',{
cidade: $pesqcidade.val()
,uf: $pesquf.val()
})
.datagrid('load');
}else{
Alert('Digite uma cidade para pesquisar.');
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment