Position in datagrid at will/Posicionarse en datagrid a voluntad

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
jgayoso
Posts: 13
Joined: Fri Jan 26, 2018 3:25 pm

Position in datagrid at will/Posicionarse en datagrid a voluntad

Post by jgayoso » Tue Feb 27, 2018 12:22 pm

I have a datagrid that displays 8 rows with the data of the alphabet. Also I have a button to search where I entered a letter to search. The idea is to display the entered data to search and display it in the following way:
J
K
L
M
N
O
P
Q
After searching you can move with the mause, usually by the datagrid.


Tengo un datagrid que despliega 8 filas con los datos del abecedario. Ademas tengo un button buscar donde ingreso una letra a buscar. La idea es desplegar el dato ingresado a buscar y mostrarlo de la siguiente forma:
J
K
L
M
N
O
P
Q
Después de buscado se pueda de desplazarse con el mause, normalmente por el datagrid.

Jorge Gayoso
Desde el sur del mundo - Chile

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9660
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Position in datagrid at will/Posicionarse en datagrid a voluntad

Post by dunbarx » Tue Feb 27, 2018 2:55 pm

Hi.

Not sure exactly what your question is.

But know that you can extract the entire contents of a dataGrid and then do anything you want within LC proper (pseudo):

Code: Select all

put the dgData of group "yourDataGrid" into temp --get the contents into a normal variable
put lineOffset(yourChar,temp) into tLine --find a char 
set the dgVScroll of group "yourDataGrid" to the value of tLine based on the textHeight, etc. of the DG
That sort of thing...

Craig Newman

jgayoso
Posts: 13
Joined: Fri Jan 26, 2018 3:25 pm

Re: Position in datagrid at will/Posicionarse en datagrid a voluntad

Post by jgayoso » Tue Feb 27, 2018 7:07 pm

Dunbarx , thank you very much.

With the instruction:

set the dgVScroll of group "yourDataGrid" to the value of tLine

I was able to solve my problem.

A great greeting from the south of the world.

Jorge Gayoso

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9660
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Position in datagrid at will/Posicionarse en datagrid a voluntad

Post by dunbarx » Tue Feb 27, 2018 11:50 pm

Great.

How did you determine the "line height"? Did you divide the formattedHeight by the number of lines?

Craig

jgayoso
Posts: 13
Joined: Fri Jan 26, 2018 3:25 pm

Re: Position in datagrid at will/Posicionarse en datagrid a voluntad

Post by jgayoso » Wed Feb 28, 2018 3:58 pm

This was my solution:

Function fPosiciona_DataGrid tTexto, tNAntes
dispatch "FindIndex" to group "DataGrid_1" with "carta_descripcion", tTexto
put the result into tNLinea_DataGrid

put (the dgProp["Row Height"] of group "DataGrid_1") * (tNLinea_DataGrid - tNAntes) into tLine

set the dgVScroll of group "DataGrid_1" to the value of tLine

set the dgHilitedIndex of group "DataGrid_1" to tNLinea_DataGrid

end fPosiciona_DataGrid

Greetings from the south of the world

Jorge Gayoso

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9660
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Position in datagrid at will/Posicionarse en datagrid a voluntad

Post by dunbarx » Wed Feb 28, 2018 6:24 pm

Aha. dgProp["Row Height"].

Much better than doing the math.

Craig

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”