01 editing a table in cxgrid

Upload: ramonet

Post on 14-Apr-2018

273 views

Category:

Documents


1 download

TRANSCRIPT

  • 7/30/2019 01 Editing a Table in CxGrid

    1/22

    Editing a table in cxGrid

    Version 1.0

    05.11.2008

    Author:Alen Markov

    Version History

    Version Date Name Description

    1.0 05.11.2008 AMA Initial Version

  • 7/30/2019 01 Editing a Table in CxGrid

    2/22

    Editing a table in cxGrid / Notes by Alen Markov Seite 2

    INHALT

    1 Question....................................................................................................................... 31.1 Testtable................................................................................................................................................. 31.2 4 Components for accessing the DB with that table .............................................................................. 4

    1.2.1 TDataSource.................................................................................................................................. 41.2.2 TIBQuery........................................................................................................................................ 51.2.3 TIBDatabase.................................................................................................................................. 61.2.4 TIBTransaction............................................................................................................................... 7

    1.3 cxGrid - DataController - Datasource ..................................................................................................... 81.4 Defining the columns which the cxGrid should display .......................................................................... 81.5 Making cells editable ............................................................................................................................ 121.6 Display.................................................................................................................................................. 131.7 Problem ................................................................................................................................................ 14

    2 Solution...................................................................................................................... 152.1 Replace TIBQuery through TIBDataset................................................................................................ 152.2 TIBDataSet ........................................................................................................................................... 16

    2.2.1 SelectSQL.................................................................................................................................... 162.2.2

    Datenmengen Editor .................................................................................................................... 18

  • 7/30/2019 01 Editing a Table in CxGrid

    3/22

    Editing a table in cxGrid / Notes by Alen Markov Seite 3

    1 Question

    I want to be able to edit a normal table in cxGrid.

    1.1 Testtable

    On the Firebird server I created a simple Testdatabase

    And inserted 2 records

  • 7/30/2019 01 Editing a Table in CxGrid

    4/22

    Editing a table in cxGrid / Notes by Alen Markov Seite 4

    1.2 4 Components for accessing the DB with that table

    Nun habe ich ein cxGrid auf's Formular gelegt. Damit die Tabelle im Grid angezeigt wird, habe ich diemarkierten 4 Komponenten auf's Formular gelegt:

    The properties of that 4 components are:

    1.2.1 TDataSource

  • 7/30/2019 01 Editing a Table in CxGrid

    5/22

    Editing a table in cxGrid / Notes by Alen Markov Seite 5

    1.2.2 TIBQuery

    The property "SQL" from TIBQuery:

  • 7/30/2019 01 Editing a Table in CxGrid

    6/22

    Editing a table in cxGrid / Notes by Alen Markov Seite 6

    1.2.3 TIBDatabase

    Property DatabaseName: LOGO20:E:\Drive_i\LtxNummer\Daten\LTXNUMMER.GDBProperty Params:

  • 7/30/2019 01 Editing a Table in CxGrid

    7/22

    Editing a table in cxGrid / Notes by Alen Markov Seite 7

    1.2.4 TIBTransaction

  • 7/30/2019 01 Editing a Table in CxGrid

    8/22

    Editing a table in cxGrid / Notes by Alen Markov Seite 8

    1.3 cxGrid - DataController - Datasource

    So the cxGrid knows which data has to be displayed, we have to choose here the DataSource:

    1.4 Defining the columns which the cxGrid should display

  • 7/30/2019 01 Editing a Table in CxGrid

    9/22

    Editing a table in cxGrid / Notes by Alen Markov Seite 9

  • 7/30/2019 01 Editing a Table in CxGrid

    10/22

    Editing a table in cxGrid / Notes by Alen Markov Seite 10

  • 7/30/2019 01 Editing a Table in CxGrid

    11/22

    Editing a table in cxGrid / Notes by Alen Markov Seite 11

  • 7/30/2019 01 Editing a Table in CxGrid

    12/22

    Editing a table in cxGrid / Notes by Alen Markov Seite 12

    1.5 Making cells editable

    Um jetzt im Grid Daten editieren zu knnen, habe ich noch diese Properties auf TRUE gesetzt:

  • 7/30/2019 01 Editing a Table in CxGrid

    13/22

    Editing a table in cxGrid / Notes by Alen Markov Seite 13

    1.6 Display

    The Grid is now showing the table:

    Clicking in a cell, the cell is marked:

  • 7/30/2019 01 Editing a Table in CxGrid

    14/22

    Editing a table in cxGrid / Notes by Alen Markov Seite 14

    Klicking on the same cell again, the cursor shows up - it seems like it's possible now to edit the cell

    1.7 Problem

    The Problem is:The cell is NOT editable!(If you try to type something, nothing shows up in the cell! The value can NOT be changed!)

  • 7/30/2019 01 Editing a Table in CxGrid

    15/22

    Editing a table in cxGrid / Notes by Alen Markov Seite 15

    2 Solution

    2.1 Replace TIBQuery through TIBDataset

    Das TDataSource zeigt jetzt auf das IBDataSet1:

    IBDataSet1 is a TIBDataSet and the property "Database" shows on "IBDatabase1":

    (The rest is the same as shown in the question above...)

  • 7/30/2019 01 Editing a Table in CxGrid

    16/22

    Editing a table in cxGrid / Notes by Alen Markov Seite 16

    2.2 TIBDataSet

    2.2.1 SelectSQL

    TIBDataSet also has a property "SelectSQL" (I inserted here the same SQL as I did before in TIBQuery).Setting the property ACTIVE to TRUE, the cxGrid is already showing the table:

  • 7/30/2019 01 Editing a Table in CxGrid

    17/22

    Editing a table in cxGrid / Notes by Alen Markov Seite 17

    Note: At this moment, the properties- DeleteSQL- InsertSQL- ModifySQL- RefreshSQL

    are all still empty...

    Compiling the whole thing, it looks the same as with the TIBQuery before:The cells are still NOT not ediable!(also note that in the Navigator the Buttons like "+" and "-" are disabled)

  • 7/30/2019 01 Editing a Table in CxGrid

    18/22

    Editing a table in cxGrid / Notes by Alen Markov Seite 18

    2.2.2 Datenmengen Editor

    To make the cells in the cxGrid ediable (and that the navigator Buttons "+" and "-" become enabled),it was necessary to do this (sorry, just have the german version - but it should be clear with the screenshots):

    Auf "Tabellenfelder lesen" klicken:

  • 7/30/2019 01 Editing a Table in CxGrid

    19/22

    Editing a table in cxGrid / Notes by Alen Markov Seite 19

    That way the SQL Statements are automatically created:

  • 7/30/2019 01 Editing a Table in CxGrid

    20/22

    Editing a table in cxGrid / Notes by Alen Markov Seite 20

  • 7/30/2019 01 Editing a Table in CxGrid

    21/22

    Editing a table in cxGrid / Notes by Alen Markov Seite 21

    Looking now in the objectinspector at the properties- DeleteSQL- InsertSQL- ModifySQL

    then the above created SQL statements can be found in them now, for example:

  • 7/30/2019 01 Editing a Table in CxGrid

    22/22

    Don't forget to set the property ACTIVE now to TRUE again.In the preview of the cxGrid you can alredady see that the navigator buttons "+" and "-" are enabled now:

    And the cells are now editable:(When you change the value of a cell this way, the database is automatically updated!)