Advertisement
Guest User

Untitled

a guest
Dec 19th, 2014
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. $(function(){
  2.  
  3. var $dgLocal = $('#data-grid-local')
  4. ,$pesqcidade = $("#pesqcidade")
  5. ,$pesquf = $("#pesquf");
  6.  
  7. $dgLocal.datagrid({
  8. autoLoad: false
  9. ,pagination: false
  10. ,rowNumber: true
  11. ,jsonStore: {
  12. url: 'Dados/cidade_json.php'
  13. }
  14. ,ajaxMethod: 'post'
  15. ,mapper:[{
  16. name: 'cidade',title:'Cidade',width:200,align:'center'
  17. },{
  18. name: 'uf',title:'UF',width:50,align:'left'
  19. }]
  20. ,eventController: {
  21. onClickRow: function(tr) {
  22. document.getElementById('cidade').value = tr.cells[1].innerHTML;
  23. document.getElementById('uf').value = tr.cells[2].innerHTML;
  24. }
  25. }
  26. });
  27.  
  28. $('#btnpesquisa').on('click',function (){
  29. if( $pesqcidade.val() !== "" ){
  30.  
  31. $dgLocal
  32. .datagrid('addParam',{
  33. cidade: $pesqcidade.val()
  34. ,uf: $pesquf.val()
  35. })
  36. .datagrid('load');
  37.  
  38. }else{
  39. Alert('Digite uma cidade para pesquisar.');
  40. }
  41. });
  42. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement