srnte01s Dosing a ClonDtaSut's Sructao Using TFelds
EMBARCA ER NETWORK
‘COMMUNITIES ARTICLES aLocs RESOURCES DOWNLOADS HELP
Defining a ClientDataSet's Structure Using TFields
By: Cary Jensen
In te last intallment of The Professional Develop, | dssnbed how o define the srscture of 9 hs
Using the Clentbsasets Meleaat rosy, nie svctute seat cent he nememary eat store when You
{areveclentbstaser's crestebaraset method. she metecatadezobing the seucsors 272 any ea
Download Trial
Sibseaueny entered nto the ClentDataet, willbe saved to ask when Wie ChantDataSets SaveToFle meth is Buy Now
von Download Delphi XE7
Wile the Pelee property powdes you with a convenient an walable mechanism for defining 2 now!
Shentoa iyo conn ve ilebe to
‘ested datasets using Ficlets, Ihave not been ble La successfully save and ten later reload these nested Coates
yd tothe CheniDelaSets native los ie formats end ter loaded ste memory Coed
Uce the FaldDatsmetnos of dining te structure of 9 ChentDataSet, you can din a ChentDataSe's structure Cea
ing Tals ether at cesign-ima oat rantime. Since the csghsime tchniue she eases to demanstate
atte with start with Defing a ChentDaasers suture using Tis at rntone Is shown later n this
Defining a ClientDataSet's Structure at Design-Time
Unfortunately, this process Is 9 bit more tedaus than that using FieHDefs, Specialy, using the FiekDefs
Incion ecto you con aulky 200 one or mae Palabet detintons each nich ses the sharacersti of 2
ding Fite. " “ mecca "
[Atnoush using he Tels method of eeinig a ClentDataset's tructre is more tme consuming, thas the
[Svantage of permiing you co dene bth tne ele of a ables svuerure forte purose of soning ca, a2 well
spi afer we oes ee eae hese ous oe comes uno ee
“The folowing steps éemonsrate hw to define» ClentOatSet's tuctre using Tels as design te: Delphi XE7
1. Puce aClentDataSet rom the Det Aces page of te Consonant Plt onto form, Dir
2 fitch Eee adc Pt aera Flr arm sho nh wing pr
nore a ees
|
oe
Bere
Osatece
Peg
jayed, as shown In the following figure. - Ce icmtheennkd
hpsedh embarcadero.comfartele!28001 6srnte01s
ofing a ClonDtaSut's Sructaro Using TFelds
Peas
ete
4. Enter PartNo inthe Name fe ana Integer he Type is eave the Fel Type rao button se tothe
‘afl, whieh Is Dat, Your Nw Fl dog box should now bok somthing Ie te allowing 70" ona ner
eohLon Goose
(22ubToals on Titer
‘5. ck OK to accept his nen el. The newly add Fld should now appear Inte lets Eco.
8. Repost steps through to add tes more fast the tab structure: For the fst Mela, et Name to
Description, Type a String, and Sze Lo 80. For (ne second el sel Nore to rice ad Type to
{Gurrency. rr the thd fel, set Name to Quantity and Type to Tateger. When you are dane the Fes
Fer shoul lok something tke the allows
Adding a Calculated Virtual Field
‘hedng a stual fl toa ChentDatasats structure a dessgn-time scaly sghty more compleated than adsng 2
ata et Tis aed complety soles seting adonal properties andor adding sadional even Mandl
Lt’ bogs by adding a eacubted fal, Cakubte fs requ beth anew fel whose types Cakelstes, nd an
‘Oncalres event Handler wich i ssccated win the ClentOataSat sal. Ths event handler used te
‘tutte the value thas wil be aplayed in tis vital ele
Note: Tis example demonsrates the action of neue vetul fel, which fava for most TDstaSat
escendonts. Akenatvely, Mes some base steps can be used toad an TnernalCale el whey 9 specal
“alsbtos ele asenanted th Clantoataset, Interna kak viral fae can be more efcane than Calle
“ua es see they need to be re-akuste es ate than estes Res
ARTICLETAGS
ClientDataset oan
2
Sogn by rght-deking the Fels Ear and sekcting New Fel (or pros NS).
Using the Rew Fk sg x, set Nomoto Total Pree, Typeto Currency, and ld Type to
Caleuated, Cee Ox to 985 te now fe
Now selec the CantDataset inthe Object Inspector or the Object TreeView, and delay the Events page of
the Object nspector
Doublcick te OncaFiele evant handler toad this evant hand, In Deli or Kx, compete this
‘event hana a own here
ce
extn “ “
SE toot client etaser1 Piabaoyhane Price") 81) and
‘isidnyane "toca Praceel-vouoe =
Pieidoytane|"Frice') else”
Adding a Virtual Aggregate Field
‘owegate fle, which can be Usd to perform a numberof automate calculations across one or more records of
‘Your data dot require event hands, but do requle that the ClentDatase ave a last one index The
Totowing ee wil walk you Uvaugh eding an Index, swell son egateaate el that wil use the dex. A more
‘amalete sscssan of ClentDstaSetinaenes wil appear n oer ble in hi sais.
4. with tre CtentDataset slated nthe Object Inspector, creas the incexDels property and deble-k the
hpsedh embarcadero.comfartele!28001srnte01s Dosing a ClonDtaSut's Sructao Using TFelds
“pss button that appears Using the inexbeecalleton extn, ce the Had New button onc,
2, With tis newly acang Indexer elected the Indexderscllcion edo, use the Obes Inspector et
[shame property to PMIndex, ana lls property to PartNo.
23, Select the GlantDataset im te Gbjct inspector ence again. Sete indexName property to PNEndex and
‘is Rapregatesacve propery to True
4, Weare now eady toad tne epgragate Fe, Double-click the ClentDateSet to display the Fae Editor
(eet, you ihe Grtoabet nad Pt ater Pome dpe
Ronse he Fels Edtor and slet New Fil.
‘Set Hare s Total Parts and DstaTyps to Aggregate, Scloct OK to clos he Naw Fld log box. The
‘puregate vial eles depayedin se own seston of she “elds Coon, 36 shown ne “allowing Pou
a
7, Solas the Total Pats aggregate fld nthe Fe Fltr, Then sing the Object Inspector, atthe
Expression oroporty to Sum(Quantity), the IncexNarve property 0 PAINdex, ar Active to Tu,
‘Thats ani takes. Al you nec to do now is cl the CreateDazaset method at runtime (or aternatve,right-cek
the GlneDataset at Zesign-ime and slet Create Dataset). Of curse, I'you want staly Se the Tesuing
‘GentDataser, you wil ao Revel hook up ta one of more dataaware central
‘Te use of he Ties efintonedeserbas hore are demonstrate in the FlaldBemo project whch you con
onload rom Code Central Tha folowing she man form of tls projec,
&
Notice tat just beow the main menu there's a Label and 2 O8.abel The DBLabel is associated With the Total
Parts aggregate fs andl used to dipy te sum othe vale entered the Quanity eld othe
‘Gent Gatssee. The DBNsviostor andthe B86 thot appear on th main form are asada withthe
‘Genebsaser through» DataSource. Ths ClentDntaSet Ie crenesat rent, # doesnot lead exit. Tiss
‘Sone from code exositd rom tne main form's Oncrete event hance, sown her
Begin “
‘As you can see fom ths cade, the CentDataset tis example ress ona data module. Upon startup, this
{hrm ealultes te name ofthe len whch the ClantDatasats data can be sore. tthe teste to see the te
[teady ext. does fal, CreateDateSet i cal, lherwst Une ChsntDalase is opened
‘The flloning Figure shows this form a runtime afer some recone have been acee
&
Creating Nested DataSet
Nestea eatavets represent one-to-many reationsip. Imagine, fr instance, that you have a Glanaaset
(Ebook) Expert Delphi: Robust and fast cross-platform application development, 2nd Edition by Marco Cantù, Pawel Glowacki ISBN 9781805121107, 1805121103 download pdf
(Ebook) Expert Delphi: Robust and fast cross-platform application development, 2nd Edition by Marco Cantù, Pawel Glowacki ISBN 9781805121107, 1805121103 download pdf