Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Message 598674
Message
From
28/12/2001 15:09:24
 
 
To
28/12/2001 04:06:39
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Miscellaneous
Thread ID:
00598680
Message ID:
00598929
Views:
16
John,
Thanks very much my friend
Regards

Peter

>Hi Peter
>
>I'll do my best to duplicate what's part of a complex formset.
>
>The users in this case are horse racing clients who want to choose what they want to see from the 35 columns available in the grid, which extends well beyond the visible area. This facility allows them to drag the columns where they want them and also change the column widths, and then save the setting for the future. They might want to have several custom settings they want to save, to enable them to toggle between various views as they study the horse's form.
>
>I've given them a default setting and 3 custom settings which they can set and toggle between. The saving is by means of 4 small command buttons, and the toggling is an optiongroup with 4 radio buttons.
>
>Here's how I approached it. I've cut and pasted this from the various parts of my formset and added some comments, so I hope I haven't left anything out.
>
>---Step 1
>
>First I created 4 tables with the names defacols, usercols, usercol2, usercol3 and the following structure. Defacols stores the default settings of the grid columns, and the others are 3 custom settings the user can save to. Structure is as follows:
>
>Form C 15
>Desc C 55
>Value N 4
>
>---Step 2
>
>My form is part of a formset, and in the Init of the formset I use the following code to store the default settings of the grid:
>
>select defacols
>delete for form='vhor_enq' and desc='thisformset.form2'
>pack
>mcolcount=thisformset.form2.grdField.ColumnCount
>n=1
>do while n<=mcolcount
> mwid='thisformset.form2.grdField.column'+alltrim(str(n))+'.width'
> mord='thisformset.form2.grdField.column'+alltrim(str(n))+'.columnorder'
> append blank
> replace form with 'vhor_enq', desc with mwid, value with &mwid
> append blank
> replace form with 'vhor_enq', desc with mord, value with &mord
> n=n+1
>enddo
>delete for empty(desc)
>pack
>
>
>---Step 3
>
>Click a button to save a setting after the columns have been dragged around, and here's what happens:
>
>cMessageTitle = ''
>cMessageText = "This will overwrite the settings in Custom 1 ... Proceed?"
>nDialogType = 4 + 16 + 256
>nAnswer = MESSAGEBOX(cMessageText, nDialogType, cMessageTitle)
>if !nAnswer = 6 && 6=yes
> return
>endif
>select usercols
>*-delete old values
>delete for form='vhor_enq' and desc='thisformset.form2'
>pack
>*-add new values
>mcolcount=thisformset.form2.grdField.ColumnCount
>n=1
>do while n<=mcolcount
> mwid='thisformset.form2.grdField.column'+alltrim(str(n))+'.width'
> mord='thisformset.form2.grdField.column'+alltrim(str(n))+'.columnorder'
> append blank
> replace form with 'vhor_enq', desc with mwid, value with &mwid
> append blank
> replace form with 'vhor_enq', desc with mord, value with &mord
> n=n+1
>enddo
>delete for empty(desc)
>pack
>mColPrev='Custom1'
>thisformset.form2.Optiongroup1.Opt1.value=0
>thisformset.form2.Optiongroup1.Opt2.value=1
>thisformset.form2.Optiongroup1.Opt3.value=0
>thisformset.form2.Optiongroup1.Opt4.value=0
>thisformset.form1.OptionGroup1.refresh
>wait window ' Column Layout Saved ' timeout 1
>
>
>---Step 4
>
>On the form is an optiongroup with 4 radio button options. Here's the code behind the Custom 1 button which is used to reload the saved column widths and order:
>
>select usercols
>set filter to form='vhor_enq' and 'thisformset.form2.grdField'$desc
>go top
>if eof()
> return
>endif
>mm=thisformset.form2.grdField
>FOR i = 1 to mm.ColumnCount
> mdesc=lower('thisformset.form2.grdField.column'+alltrim(str(i))+'.width')
> locate for lower(desc)=mdesc
> mm.Columns(i).width=usercols.value
> mdesc=lower('thisformset.form2.grdField.column'+alltrim(str(i))+'.columnorder')
> locate for lower(desc)=mdesc
> mm.Columns(i).columnorder=usercols.value
>ENDFOR
>this.value=1
>set filter to
>mCusMode='Custom1'
>thisformset.form2.grdField.column4.setfocus
>thisform.refresh
>
>
>---Step 5
>
>I keep track of what mode I'm in with public variable mCusMode. I also provide a facility which allows the user to store his preferences for which setting he'd like to see when the form loads, and I use code similar to step 4 above in the formset Init AFTER the grid's defaults settings have been stored.
>
>
>
>Hope you can make use of it.
Previous
Reply
Map
View

Click here to load this message in the networking platform