sisapc

by Hassim Navarrete

HTML

<table id="dg" title="Datagrid" style="width:800px;height:300px" data-options="
  //view: scrollview,
  singleSelect:true,
  rownumbers:true,
  fitColumns:true,
  nowrap:true,
  striped:true,
  data:data,
  onLoadSuccess:function()
  {
    console.log('onLoadSuccess');
  },
  toolbar: '#toolbar'
">
  <thead frozen="true">
    <tr>
      <th data-options="field:'folio', align:'center'">Folio</th>
      <th data-options="field:'nombre_apc',align:'left'">Nombre del APC</th>
      <th data-options="field:'nombre_completo',align:'left'">Propietario(s)</th>
    </tr>
  </thead>

  <thead>
    <tr>
      <th data-options="field:'hectareas',align:'left'">Superficie</th>
      <th data-options="field:'estado',align:'left'">Estado</th>
      <th data-options="field:'municipio',align:'left'">Municipio</th>
      <th data-options="field:'localidad',align:'left'">Localidad</th>
    </tr>
  </thead>
</table>

<div id="toolbar" style="padding:3px">
  <a id="btnRemoveFilter">Clear filter</a>
  <span class="button-sep"></span>
</div>

CSS

</style> <link rel="stylesheet" type="text/css" href="https://www.jeasyui.com/easyui/themes/material/easyui.css"> <link rel="stylesheet" type="text/css" href="https://www.jeasyui.com/easyui/themes/icon.css"> <link rel="stylesheet" type="text/css" href="https://www.jeasyui.com/easyui/demo/demo.css"> <script type="text/javascript" src="https://code.jquery.com/jquery-1.7.1.min.js"></script> <script type="text/javascript" src="https://www.jeasyui.com/easyui/jquery.easyui.min.js"></script> <script type="text/javascript" src="https://www.jeasyui.com/easyui/locale/easyui-lang-es.js"></script> <script type="text/javascript" src="https://www.jeasyui.com/easyui/datagrid-filter.js"></script> <script type="text/javascript" src="https://www.jeasyui.com/easyui/datagrid-scrollview.js"></script> <style>

JavaScript

var data = [{
  "folio": "0294",
  "nombre_apc": "El Guayabal 2",
  "nombre_completo": "Zeferino Franco Cuevas"
}, {
  "folio": "0293",
  "nombre_apc": "Calpixcan 6",
  "nombre_completo": "Maria De Los Dolores Guapillo Alarcon"
}, {
  "folio": "0156",
  "nombre_apc": "Guayabal",
  "nombre_completo": "José Ernesto Justino Mavil Valdivia"
}, {
  "folio": "0155",
  "nombre_apc": "Parcela 349",
  "nombre_completo": "Gaudencio Cuavichi García"
}, {
  "folio": "0154",
  "nombre_apc": "La Laja",
  "nombre_completo": "Zeferino Franco Cuevas",
}]

$(function() {
  var dg = $('#dg').datagrid();

  dg.datagrid('enableFilter', [
  {
    field: 'folio',
    type: 'textbox',
    options: 
    {
      onChange: function(value) 
      {
        if (value == '') 
        {
          dg.datagrid('removeFilterRule', 'folio');
        } 
        else 
        {
          dg.datagrid('addFilterRule', {
            field: 'folio',
            op: 'contains',
            value: value
          });
        }
        dg.datagrid('doFilter');
      }
    }
  }, 
  {
    field: 'nombre_apc',
    type: 'textbox',
    options: 
    {
      onChange:function(value)
      {
      if (value == '') 
        {
          dg.datagrid('removeFilterRule', 'nombre_apc');
        } 
        else 
        {
          dg.datagrid('addFilterRule', {
            field: 'nombre_apc',
            op: 'contains',
            value: value
          });
        }
        dg.datagrid('doFilter');
      }
    }
  }, 
  {
    field: 'nombre_completo',
    type: 'textbox',
    options: 
    {     
      onChange: function(value) 
      {
        if (value == '') 
        {
          dg.datagrid('removeFilterRule', 'nombre_completo');
        } 
        else 
        {
          dg.datagrid('addFilterRule', {
            field: 'nombre_completo',
            op: 'contains',
            value: value
          });
        }
        dg.datagrid('doFilter');
      }
    }
    },
    {field:'hectareas', type:'label'}, 
 ...