Hi Everyone,
I know it is a lot about this Subject, but i have not found any similar to my needs, besides it is the first time i want to do this.
In my case i have form and in that form, i just droped the grid control, that grid is fill with data when the SELECT SQL is executed, so the grid's columns, header are created on the fly by the Select sql.
I am wondering if any one can guide me here, in my case to be able to do a sort when clicking on the grid header, below is some code i used to fill in the grid, i have a command search, that run the code below, if you can help me here how to treat this to be able to allow users to click the headers to sort, will be very nice
So the grid will be filled with the cursor RESULS2 as you can see, so i am assuming here that we need some code before the "ELse" command to make this grid able to be sorted on each column, any help very appreciated
Thanks
I know it is a lot about this Subject, but i have not found any similar to my needs, besides it is the first time i want to do this.
In my case i have form and in that form, i just droped the grid control, that grid is fill with data when the SELECT SQL is executed, so the grid's columns, header are created on the fly by the Select sql.
I am wondering if any one can guide me here, in my case to be able to do a sort when clicking on the grid header, below is some code i used to fill in the grid, i have a command search, that run the code below, if you can help me here how to treat this to be able to allow users to click the headers to sort, will be very nice
So the grid will be filled with the cursor RESULS2 as you can see, so i am assuming here that we need some code before the "ELse" command to make this grid able to be sorted on each column, any help very appreciated
Code:
thisform.Refresh()
doevents
PUBLIC lcJob_no
SET EXCLUSIVE OFF
SET SAFETY OFF
SET CPDIALOG OFF
lcjob_no= thisform.txtTextBox.Value
thisform.label5.VISIBLE=.t.
thisform.label5.Enabled=.t.
path_1="S:\PRO50\APEX04\POTRAN04" &&VFP 5.0 TABLE TYPE
path_2="F:\MFG\ENG_JOBS" && FOXPRO DOS 2.0 TABLE
path_3="F:\MFG\INS_LOG" && FOXPRO DOS 2.0 TABLE
path_4 ="s:\pro50\apex04\apvend04" &&VFP 5.0 TABLE TYPE
path_5="s:\pro50\apex04\pomast04"
Select INT(VAL(t1.dept)) as ball_no, sht as Sheet, INT(t1.QtyOrd) as QTYORD, INT(t1.Qtyrec) as QTYREC,T5.PURDATE,T5.REQDATE,T5.BUYER, t4.company as VendorName, t2.part_type as PRC, t2.draw_no, t1.item as ItemNo, t1.vpartno as vendorpartno, ;
t1.descrip, t1.Recdate, t1.purno ;
From (path_1) t1 ;
INNER Join (path_2) t2;
ON INT(VAL(t2.ball_no)) = INT(VAL(t1.dept));
INNER JOIN (path_4) t4;
ON t1.vendno = t4.vendno;
INNER JOIN (PATH_5) T5;
ON T1.PURNO = T5.PURNO ;
WHERE t1.reqno= lcJob_no AND t2.job_no=lcJob_no ;
ORDER BY 1,2,8 INTO Cursor RESULS1 readwrite
Local lnValue, lcSuffix, lcSheet
Scan
lnValue = ball_No
lcSuffix = Iif(Between(Asc(Right(Alltrim(draw_no),1)),48,57),'',Right(Alltrim(draw_no),1))
Do Case
Case Between(m.lnValue,1,999)
lcSheet = substr(ALLTRIM(Transform(m.lnValue,"9999999")),1,1)+m.lcSuffix
* Since converting character to integer will loose zeroes on
* the > left, then override those that are less than 200
If m.lnValue < 200
lcSheet = '1'+m.lcSuffix
Endif
Case Between(m.lnValue,8000,8999)
lcSheet = ''
Case Between(m.lnValue,7000,7999)
lcSheet = '7'+m.lcSuffix
Case Between(m.lnValue,9000,9999)
lcSheet = '9'+m.lcSuffix
Otherwise
lcSheet = substr(ALLTRIM(Transform(m.lnValue,"9999999")),2,1)+m.lcSuffix
Endcase
Replace sheet With m.lcSheet
ENDSCAN
GO top
Select ball_no, Sheet, QTYORD, QTYREC,PURDATE,REQDATE,BUYER, VendorName, PRC, ItemNo, vendorpartno, ;
descrip, Recdate, purno;
From RESULS1 ORDER BY 1 INTO Cursor RESULS2 readwrite
thisform.label5.VISIBLE=.f.
thisform.label5.Enabled=.f.
If _Tally > 0
With Thisform.grid2
.Visible = .T.
.ColumnCount = -1
.RecordSource = 'resuls2'
.Refresh()
.Setall("DynamicBackColor", "IIF(resuls2.qtyord = resuls2.qtyrec, RGB(255,255, 0), 0xFFFFFF)") &&255, 255, 0 yellow
.Column3.DynamicForeColor= "IIF(resuls2.qtyord= resuls2.qtyrec, RGB(255,0,0),RGB(0,0,0))"
.Column4.DynamicForeColor= "IIF(resuls2.qtyord= resuls2.qtyrec, RGB(255,0,0),RGB(0,0,0))"
ENDWITH
THISFORM.SSGRIDLOCK1.Enabled= .T.
THISFORM.SSGRIDLOCK1.VISIBLE= .T.
thisform.buttonx1.Visible = .t.
Thisform.buttonx1.Enabled =.T.
Thisform.Sstoexcel21.Enabled=.T.
Thisform.command4.Enabled=.T.
Thisform.command2.Enabled=.T.
thisform.command1.Enabled= .F.
thisform.label8.Visible = .T.
thisform.label3.Enabled=.T.
thisform.label3.VISIBLE=.T.
Thisform.Text1.visible=.T.
thisform.label7.VISIBLE=.t.
Else
Messagebox('There is not result for your Query, Check again your Entry',0+64,'Ok!')
thisform.command1.Enabled= .F.
Thisform.command4.enabled=.F.
Thisform.command2.enabled=.t.
thisform.label3.Enabled=.f.
thisform.label3.VISIBLE=.f.
thisform.buttonx1.Visible = .f.
Thisform.buttonx1.Enabled =.f.
Thisform.TxtTextBox.Value=''
thisform.label7.VISIBLE=.f.
Thisform.Text1.visible=.F.
Thisform.TxtTextBox.SetFocus
With Thisform.grid2
.Visible = .F.
.ColumnCount = -1
.RecordSource = ''
Endwith
Endif
Thanks