Power Builder - Una Gran ayuda en una busqueda

 
Vista:

Una Gran ayuda en una busqueda

Publicado por Marco (31 intervenciones) el 09/01/2008 17:37:56
Hola a todos me gustaria hacer un busqueda.

primero tengo una lista de medico codigo, nombres .....etc. el datawin esta lleno de medicos.
luego quiero cuando ingrese los primeros caracteres y me vallan apareciendo solo los medicos con los primeros caracteres

osea que me filtre al comenzar la busqueda
espero su gentil ayuda no tengo ni idea novato en power
gracias

lima -peru
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de antonio
Val: 176
Bronce
Ha mantenido su posición en Power Builder (en relación al último mes)
Gráfica de Power Builder

RE:Una Gran ayuda en una busqueda

Publicado por antonio (1271 intervenciones) el 09/01/2008 23:33:48
Hola Marco:

utiliza la funcion de "LIKE%", en pb trae mucha ayuda de como realizarla, esta funcion la puedes hacer como filtro o como un retrieve.

Saludos desde México
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:Buscar digitando los primeros caracteres

Publicado por oscar (1178 intervenciones) el 10/01/2008 00:22:21
Para buscar digitando los primeros caracteres, quizá te podría servir el siguiente ejemplo:

http://www.lawebdelprogramador.com/news/mostrar_new.php?id=73&texto=Power+Builder&n1=269794&n2=1&n3=0&n4=0&n5=0&n6=0&n7=0&n8=0&n9=0&n0=0
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:Buscar digitando los primeros caracteres

Publicado por marco  (31 intervenciones) el 10/01/2008 22:26:51
bueno sirve hasta un punto
loque hace esta bien pero si yo tubiera tres nonbres con el mismo apellido nome deja seleccionar al medico porque siempre me direcciona al texbox para selecionar el otro medico con las teclas direccionnales
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:Buscar digitando los primeros caracteres

Publicado por wend (95 intervenciones) el 11/01/2008 14:19:49
Saludos, te envío un objeto que lo baje de la web.
Para usarlo colocas el siguiente código en el evento open:
sle_busca.initdw( dw_search, 'nombrecolumna' )

Este código lo copias en el block de notas lo guardas con un nombre, por ejemplo sle_busca.sru y luego lo importas a tu librería.

$PBExportHeader$sle_busca.sru
$PBExportComments$Busca el texto que se va ingresando en este objeto en un campo de tipo string de un DW y se coloca en la fila encontrada.
forward
global type sle_busca from singlelineedit
end type
end forward

global type sle_busca from singlelineedit
integer width = 411
integer height = 84
integer taborder = 1
integer textsize = -8
integer weight = 400
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "MS Sans Serif"
long textcolor = 33554432
boolean autohscroll = false
borderstyle borderstyle = stylelowered!
event key_press pbm_keydown
end type
global sle_busca sle_busca

type variables
PRIVATE:
long il_selectedrow
string is_filter

Long il_parm
String is_parm, is_tipodato
Integer ii_campo

datawindow idw_Search
string is_ColName
boolean ib_Init = FALSE
end variables

forward prototypes
public function boolean initdw (ref datawindow adw_search, string as_colname)
end prototypes

event key_press;int li_movement
long ll_row

If KeyDown (keyUparrow!) then
li_movement = -1
End If

If KeyDown (keyDownarrow!) then
li_movement = 1
End If

If li_movement <> 0 Then
idw_search.SetRedraw(False)
ll_row = idw_search.GetSelectedRow(0)
ll_row = ll_row + li_movement
If ll_row < 1 or ll_row > idw_search.RowCount( ) Then
Beep(1)
Return
End If
idw_search.selectrow(0,False)
idw_search.SelectRow(ll_row , True)
idw_search.ScrollToRow (ll_row)
This.text = idw_search.GetItemString(ll_row , is_colname)
is_filter = This.text
il_selectedrow = ll_row
idw_search.SetRedraw(True)
This.SelectText(len(This.text) + 1,0)
message.processed = true
Return
End If

string ls_character
long ll_found_row
int li_num_chars

ls_character = Char(message.wordparm)

/* Descomentar esto para que controle que busque solo letras
If ls_character <> " " Then
If (Lower(ls_character) < "a" or Lower(ls_character) > "z") and ls_character <> Char(8) Then
message.processed = true
Return
End If
End If */

If message.wordparm = 8 then
li_num_chars = Len(is_filter)
If li_num_chars > 0 then is_filter = Left(is_filter, li_num_chars -1)
else
is_filter = is_filter + ls_character
end if

If Len(is_filter) > 0 Then
ll_found_row = idw_search.Find("Lower("+is_colname+") LIKE ~"" + Lower(is_filter) + "%~"",1, 99999)
If ll_found_row > 0 then
idw_search.SetRedraw(FALSE)
idw_search.SelectRow(0, FALSE)
idw_search.ScrollToRow(ll_found_row)
idw_search.SelectRow(ll_found_row, TRUE)
idw_search.SetRedraw(TRUE)
Else
Beep(1)
li_num_chars = Len(is_filter)
If li_num_chars > 0 Then is_filter = Left(is_filter, li_num_chars -1)
message.processed = true
End If
Else
idw_search.SelectRow(0, FALSE)
End If
end event

public function boolean initdw (ref datawindow adw_search, string as_colname);/********************************************************************
initdw

<DESC> Set a datawindow instance variable with the datawindow
passed to this method. Also, set the column that in which
the developer wants the search to be performed. </DESC>

<RETURN> boolean:
<LI> TRUE, Initialized OK
<LI> FALSE, Initialize failed </RETURN>

<ACCESS> Public

<ARGS> adw_Search: Datawindow in which the search is to be
performed
as_ColName: Column name to search for the entered value.
</ARGS>

<USAGE> If sle_find.initdw( dw_search, 'KeyCol' ) Then ...
</USAGE>

********************************************************************/

String ls_ColType

If as_ColName = "" Then RETURN FALSE

idw_Search = adw_Search
is_ColName = as_ColName

ls_Coltype = idw_Search.Describe(is_ColName+".coltype")
If Lower( Left( ls_Coltype, 4 ) ) <> "char" Then RETURN FALSE

ib_Init = True

RETURN TRUE
end function

on sle_busca.create
end on

on sle_busca.destroy
end on
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar