Foros del Web » Programando para Internet » Javascript » Frameworks JS »

SearchField EXTJS

Estas en el tema de SearchField EXTJS en el foro de Frameworks JS en Foros del Web. Buenas tardes, he incorporado la búsqueda en mi grid, a partir de un ejemplo que encontré en la red. El caso es que la búsqueda ...
  #1 (permalink)  
Antiguo 24/10/2011, 08:32
 
Fecha de Ingreso: febrero-2007
Mensajes: 56
Antigüedad: 17 años, 2 meses
Puntos: 1
SearchField EXTJS

Buenas tardes,

he incorporado la búsqueda en mi grid, a partir de un ejemplo que encontré en la red. El caso es que la búsqueda me funciona perfectamente, el problema viene cuando quiero cancelar dicha búsqueda, es decir, volver a mostrar todos los registros (onTrigger1Click) ya que me muestra el grid vacío.

Les dejo mi código a ver alguien puede saber qué puedo estar haciendo mal.

Gracias de antemano!!!

searchfield.js


Código:
Ext.app.SearchField = Ext.extend(Ext.form.TwinTriggerField, { 
initComponent : function() { 
Ext.app.SearchField.superclass.initComponent.call(this); 
this.on('specialkey', function(f, e) { 
if (e.getKey() == e.ENTER) { 
this.onTrigger2Click(); 
} 
}, this); 
}, 

validationEvent : false, 
validateOnBlur : false, 
trigger1Class : 'x-form-clear-trigger', 
trigger2Class : 'x-form-search-trigger', 
hideTrigger1 : true, 
width : 180, 
emptyText : 'Introduzca Criterio ...', 
hasSearch : false, 
paramName : 'query', 

onTrigger1Click : function() { 
if (this.hasSearch) 
{ 
var o = { 
start : 0, 
limit : 20 
}; 
this.store.baseParams = this.store.baseParams || {}; 
this.store.baseParams[this.paramName] = ''; 
this.store.reload({ 
params : o 
}); 
this.triggers[0].hide(); 
this.hasSearch = false; 
} 
}, 

onTrigger2Click : function() { 
var v = this.getRawValue(); 
if (v.length < 1) { 
this.onTrigger1Click(); 
return; 
} 
var o = { 
start : 0, 
limit : 20 
}; 
this.store.baseParams = this.store.baseParams || {}; 
this.store.baseParams[this.paramName] = v; 
this.store.reload({ 
params : o 
}); 
this.hasSearch = true; 
this.triggers[0].show(); 
} 
});
getContacts1.php

Código:
<?php
$connection= mysql_connect("localhost","kszwsoso_ugespro","ugespro") or die("Connection Failed".mysql_error()); 
mysql_select_db("kszwsoso_gestorproyectos",$connection)or die("Error loading the DataBase".mysql_error()); 

//Paginación 
$start=isset($_POST["start"])?$_POST["start"]:0; 
$limit=isset($_POST["limit"])?$_POST["limit"]:15; 

//Control Búsqueda 
if ( isset($_POST["query"]) ) 
{ 
$result= mysql_query("SELECT coddelegacion,descdelegacion,descsubdelegacion,domiciliodelegacion,poblaciondelegacion,provinciadelegacion,descprovincia,codpostaldelegacion,telefonodelegacion,faxdelegacion,emaildelegacion FROM gestdelegaciones001,gestprovin001 WHERE gestdelegaciones001.provinciadelegacion=gestprovin001.idprovincia AND baja=0 AND ( descdelegacion LIKE '".$_POST["query"]."' OR codpostaldelegacion LIKE '".$_POST["query"]."' OR provinciadelegacion LIKE '".$_POST["query"]."')"); 
} 
else 
{ 
$result= mysql_query("SELECT coddelegacion,descdelegacion,descsubdelegacion,domiciliodelegacion,poblaciondelegacion,provinciadelegacion,descprovincia,codpostaldelegacion,telefonodelegacion,faxdelegacion,emaildelegacion FROM gestdelegaciones001,gestprovin001 WHERE gestdelegaciones001.provinciadelegacion=gestprovin001.idprovincia AND baja=0"); 
} 

$data= array(); 
$metadata = array(); 

while($row= mysql_fetch_array($result)){ 
array_push($data,array( 
"coddelegacion"	=> $row["coddelegacion"], 
"descdelegacion"	=> $row["descdelegacion"], 
"descsubdelegacion"	=> $row["descsubdelegacion"], 
"domiciliodelegacion"	=> $row["domiciliodelegacion"], 
"poblaciondelegacion"	=> $row["poblaciondelegacion"], 
"provinciadelegacion"	=> $row["provinciadelegacion"], 
"codpostaldelegacion"	=> $row["codpostaldelegacion"], 
"telefonodelegacion"	=> $row["telefonodelegacion"], 
"faxdelegacion"	=> $row["faxdelegacion"], 
"emaildelegacion"	=> $row["emaildelegacion"] 
)); 
} 

echo json_encode( 
array( 
"success"	=> true, 
"total"	 => count($data), 
"data"	 => array_splice($data,$start,$limit) 
));

crud0.js

Código:
.......................................... 

//Búsqueda 
var searchUsers = new Ext.app.SearchField({ 
store : this.storeGrid, 
width: 180, 
id: 'fieldUsersSearch' 
}); 

//this.grid.on('afteredit',this.aviso); 

var pager = new Ext.PagingToolbar 
({ 
store: this.storeGrid, 
displayInfo:true, 
displayMsg:"{0} - {1} of {2} Delegaciones", 
emptyMsg: "No Hay Datos Que Mostrar", 
pageSize:15 
} 
); 




var win = new Ext.Window({ 
title	: "eProject - Gestión Delegaciones", 
layout	: "fit", 
tbar	: [ 
{text:'Añadir Registro', scope:this, handler:this.addContact,iconCls:'save-icon'}, 
{text:"Eliminar Registro", scope:this, handler:this.onDelete,iconCls:'delete-icon'}, 
{text:"Exportar", scope:this, handler:this.exportPDF,iconCls:'pdf-icon'}, 
{text:"Exportar", scope:this, handler:this.exportExcel,iconCls:'excel-icon'}, 
searchUsers, 
'->', 
{text:"Ayuda", scope:this, handler:this.ayuda,iconCls:'help-icon'} 
], 
width	: 1000, 
height	: 435, 
x:0, 
y:10, 
bbar: pager, 
items	: [this.grid] 
}); 
win.show(); 

.........................................................

Etiquetas: extjs, funcion, js, php
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 06:40.