Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Grid content diont oprder correctly
Message
From
15/03/2024 06:36:01
Luis Santos
Biglevel-Soluções Informáticas, Lda
Portugal
 
 
To
13/03/2024 15:02:18
Lutz Scheffler (Online)
Lutz Scheffler Software Ingenieurbüro
Dresden, Germany
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01687690
Message ID:
01687728
Views:
40
Luis,
1)
Low level test. Is your cursor ordered (i.e what is the result of BROWSE) after SET ORDER? Just issue BROWSE NOWAIT after the sorting method ....

2)
Have you considered to SET ORDER like
SET ORDER TO tag instead of SET ORDER TO tag_number ? Like
SET ORDER TO i_dat  ...
3)
Consider to REFRESH the grid after the change of SET ORDER. It might not be as simple as just grid.refresh, I have a rather complex method that refreshes the grid after sorting to keep active row visible. It is decades old and working, and I do not understand it at first glance. Older then eventbinding ...

Lutz

>Hi community,
>
>I have a grid on my form and i place code inside them to order on click header but they don´t work correctly especially when the column is of the date type.
>I think the column index gets messed up.
>Because clicking on the customer name column doesn't work either.
>I don't know what else to do!!!
>Can someone please help me?
>

Hi Lutz,

With this changes , now i can ordering my grid, but only ascending and not descending ?
*fecha('crMonitorFacturas')
RELEASE ge_snnocalfis


local consulta
consulta=''


if empty(m.ObjRecebido.Janela.pageframe1.page1.dtini.Value) or datavazia(m.ObjRecebido.Janela.pageframe1.page1.dtini.Value)
	m.ObjRecebido.Janela.pageframe1.page1.dtini.Value=date(1900, 1, 1)
endif 

if empty(m.ObjRecebido.Janela.pageframe1.page1.dtfim.Value) or datavazia(m.ObjRecebido.Janela.pageframe1.page1.dtfim.Value)
	m.ObjRecebido.Janela.pageframe1.page1.dtfim.Value=  date(1900, 1, 1) &&date(year(date()), 12, 31)
endif

if !empty(PDU_Riesgo.Pageframe1.Page1.ftObj12.Value)
	consulta=(" and ft.nome='"+alltrim(PDU_Riesgo.Pageframe1.Page1.ftObj12.Value)+"'")
endif

if !empty(m.ObjRecebido.Janela.pageframe1.page1.ftobj17.Value) 
	consulta=consulta+(" and ft.nmdoc='"+alltrim(m.ObjRecebido.Janela.pageframe1.page1.ftobj17.Value)+"'")
endif


if !empty(m.ObjRecebido.Janela.pageframe1.page1.ftobj18.Value) 
	consulta=consulta+(" and ft.fno="+alltrim(m.ObjRecebido.Janela.pageframe1.page1.ftobj18.Value))
endif

if !empty(m.ObjRecebido.Janela.pageframe1.page1.ftobj20.Value) 
	consulta=consulta+(" and ft.tpdesc='"+alltrim(m.ObjRecebido.Janela.pageframe1.page1.ftobj20.Value)+"'")
endif


Text To usql Textmerge Noshow pretext 7
select ft.nmdoc, ft.fno,cast( ft.fdata AS DATE ) as fdata , cast(ft.pdata as DATE)  as pdata, ft.nome, iif (cc.cm = 1, cc.edeb - cc.edebf, -(cc.ecred - cc.ecredf)) as pendiente, ft.etotal, ft.ettiliq, ft.ettiva, ft.ccusto, ft.plano, ft.ftstamp, ft.ndoc, case ft.pais when 1 then 'Nacional' when 2 then 'U.E.' when 3 then 'Otros' end as pais, (select pncont from cl (nolock) where no=ft.no and estab=ft.estab) as pncont
from ft (nolock)
join cc (nolock)
on cc.ftstamp=ft.ftstamp
where ft.ndoc in (1,4) and cc.situacao=1 and ft.anulado=0 and ft.fdata between '<<dtosql(m.ObjRecebido.Janela.pageframe1.page1.DTINI.Value)>>' and '<<dtosql(m.ObjRecebido.Janela.pageframe1.page1.DTFIM.Value)>>' <<consulta>>
order by  3
endtext


IF NOT u_sqlexec(usql, 'crMonitorFacturas')
msg(usql)
Else
u_sqlexec(usql, 'crMonitorFacturas')

PDU_RIESGO.pageframe1.page1.Obj1.Refresh()

select sum(etotal) as 'Total' , count(*) as 'reg' from crMonitorFacturas  into Cursor Crstotal
select crstotal
PDU_RIESGO.Pageframe1.Page1.FTValorOBJ21.Value = crstotal.Total
PDU_RIESGO.Pageframe1.Page1.FTnrregOBJ23.Value = crstotal.reg

FECHA([Crstotal])

Set DATE BRIT
Set Date DMY && ddmmyy
Set Century On



Select crMonitorFacturas
Index On crMonitorFacturas.FDATA Tag i_dat
Index On crMonitorFacturas.PDATA Tag i_venc
Index On crMonitorFacturas.NOME Tag i_nm
Index On crMonitorFacturas.PENDIENTE Tag i_pend
Index On crMonitorFacturas.ETOTAL Tag i_tot


Go Top In crMonitorFacturas

Endif



Public m_monitor_MAPAUTENTE

*!* Crias o teu obj
m_monitor_MAPAUTENTE=Newobject("new_MAPAUTENTE")

*!* executar o procedimento que faz Bindevent
Do sp_eventOBJ

*!* Criar a classe
Define Class new_MAPAUTENTE As Session


	Procedure Ordenarfecha

		Select crMonitorFacturas
		If Val(Sys(21))<> 3 && current index number
			Set Order To i_dat In crMonitorFacturas
		Else
			If Descending(i_dat,"crMonitorFacturas")
				Set Order To i_dat In crMonitorFacturas Ascending
			Else
				Set Order To i_dat In crMonitorFacturas Descending
			Endif
		Endif

		Go Top In crMonitorFacturas
		PDU_Riesgo.pageframe1.page1.Obj1.Refresh()
	Endproc



	Procedure OrdenarVenc

		If Val(Sys(21)) <> 4 && current index number
			Set Order To i_venc In crMonitorFacturas
		Else
			If Descending(i_venc,"crMonitorFacturas")
				Set Order To i_venc In crMonitorFacturas Ascending
			Else
				Set Order To i_venc In crMonitorFacturas Descending
			Endif
		Endif

		Go Top In crMonitorFacturas
		PDU_Riesgo.pageframe1.page1.Obj1.Refresh()
	Endproc

	Procedure OrdenarCliente

		Select crMonitorFacturas
		If Val(Sys(21)) <> 5  && current index number
			Set Order To i_nm In crMonitorFacturas
		Else
			If Descending(i_nm,"crMonitorFacturas")
				Set Order To i_nm In crMonitorFacturas Ascending
			Else
				Set Order To i_nm In crMonitorFacturas Descending
			Endif
		Endif

		Go Top In crMonitorFacturas
		PDU_Riesgo.pageframe1.page1.Obj1.Refresh()
	Endproc

	Procedure OrdenarPendente

		Select crMonitorFacturas
		If Val(Sys(21)) <> 6  && current index number
			Set Order To i_pend In crMonitorFacturas
		Else
			If Descending(i_pend,"crMonitorFacturas")
				Set Order To i_pend In crMonitorFacturas Ascending
			Else
				Set Order To i_pend In crMonitorFacturas Descending
			Endif
		Endif

		Go Top In crMonitorFacturas
		PDU_Riesgo.pageframe1.page1.Obj1.Refresh()

	Endproc

	Procedure OrdenarTotal

		Select crMonitorFacturas
		If Val(Sys(21)) <> 7  && current index number
			Set Order To i_tot In crMonitorFacturas
		Else
			If Descending(i_tot,"crMonitorFacturas")
				Set Order To i_tot In crMonitorFacturas Ascending
			Else
				Set Order To i_tot In crMonitorFacturas Descending
			Endif
		Endif

		Go Top In crMonitorFacturas
		PDU_Riesgo.pageframe1.page1.Obj1.Refresh()

	Endproc


enddefine


*****************************************************************************************
*Fim da Classe - Separador Utentes      						                 		*
*Criar o procedimento sp_eventOBJ que faz o "Bindevent"	aos objectos					*
*****************************************************************************************
Procedure sp_eventOBJ


	Bindevent(PDU_RIESGO.pageframe1.page1.Obj1.column3.header1,"click",m_monitor_MAPAUTENTE,"Ordenarfecha",1)
	Bindevent(PDU_RIESGO.pageframe1.page1.Obj1.column4.header1,"click",m_monitor_MAPAUTENTE,"Ordenarvenc",1)
	Bindevent(PDU_RIESGO.pageframe1.page1.Obj1.column5.header1,"click",m_monitor_MAPAUTENTE,"OrdenarCliente",1)
	Bindevent(PDU_RIESGO.pageframe1.page1.Obj1.column6.header1,"click",m_monitor_MAPAUTENTE,"OrdenarPendente",1)
	Bindevent(PDU_RIESGO.pageframe1.page1.Obj1.column7.header1,"click",m_monitor_MAPAUTENTE,"OrdenarTotal",1)

Endproc
Previous
Reply
Map
View

Click here to load this message in the networking platform