[Gambas-user] Re; Grid [New version available]

Gareth Bult gareth at ...1689...
Mon May 14 17:50:09 CEST 2007


Ok,

I see what you mean.

There's an additional issue here in that you want to select from an additional table, but you don't actually want to display the contents of the table, but the result of an integer -> String lookup field.

This is something the editor needs to do , but does not at the moment.

If you'd like to add it as a feature request to the tracker I'll try to get to it in the next couple of days ..

Essentially you will want the display to show the result of a join (i.e. the name from the other table) , and the editor / store command to work with the integer key .. so I guess the initial select will need to include both .. and the key will be hidden but used by the editor .. should be interesting .. :)

..

Gareth

----- Original Message -----
From: "Steven Lobbezoo" <steven at ...1652...>
To: "mailing list for gambas users" <gambas-user at lists.sourceforge.net>
Sent: Monday, May 14, 2007 4:24:27 PM (GMT) Europe/London
Subject: Re: [Gambas-user] Re; Grid [New version available]

Ok, thats nice, but ...

Putting a select into a combo field is not that complicated.
I build an array of values (strings) at form load and then do :
      IF hStr THEN 
        grid.Show_Combo(hStr, FALSE)
      END IF
in the MyGrid.Edit sub. No problèmo. 

Let me explain my problem in a better way :

In my grid i have the following columns:

No | Type | Name Town | Name client

In the database I have the table with the following fields :

No		Integer	Autoincr.		Primary key
Type	String	Filled trough a combo box with fixed values (no problem there)
Town	Integer	Reference to a towns table with names of towns in there
Client	Integer	Reference to a clients table with names of clients in there

Now, I want the user to get a combo display with names, and update the table 
with the corresponding (after the user selected) references.

This, the grid refuses, since it does not recognise a select statement with 2 
linked tables. (I tried it with 'extra' columns with their width set to 0)

Steven






Le lundi 14 mai 2007 16:44, Gareth Bult a écrit :
> Ok,
>
> It didn't .. ;-)
>
> If you download the latest version (0.1.63) you will have access to a
> method called "putData"; putData(row,col,Value)
>
> This will put something to the table buffer at the desired coordinates and
> move the cursor to this spot. (highlighted in red as a changed value)
>
> Also, in this version you can use SELECT statements to fill drop-down
> combo's for dynamic editor choices .. :)
>
> Gareth.
>
>
>
>
> ----- Original Message -----
> From: "Steven Lobbezoo" <steven at ...1652...>
> To: "mailing list for gambas users" <gambas-user at lists.sourceforge.net>
> Sent: Monday, May 14, 2007 2:18:47 PM (GMT) Europe/London
> Subject: Re: [Gambas-user] Re; Grid
>
> Hi Gareth,
>
> I'm toying around a bit with your dbgrid.
> It looks just fine, but I have one major problem.
> I've tables with references to other tables. I want the user to see an
> other column in the refrenced table, but after he selects some value there
> (works ok) i want to do the update on the original table with the reference
> value.
>
> Can this be done with your grid?
>
> Steven
>
> Le vendredi 4 mai 2007 11:55, Gareth Bult a écrit :
> > Ok, incorporated into the component - seems to work fine .. :)
> > New release at http://encryptec.net/software/gambas-grideditor
> >
> > I now have tiered chaining working based on "change" events ..
> > i.e. (n) tables linked in a master-slave hierarchy where the slave(s)
> > auto-update when someone changes rows on the master ..
> > (screen shot on the page)
> >
> > Gareth.
> >
> > On Fri, 2007-05-04 at 10:25 +0100, Gareth Bult wrote:
> > > Hi,
> > >
> > > Thanks for that .. one problem I have however .. when you click (or
> > > double click) on a header , it doesn't generate an Mouse event.
> > > ... it only generates an event if you're over the grid ...
> > >
> > > However, playing with mouse clicks has I think led to a solution.
> > >
> > > A double click on a header generates a DblClick.
> > > A double click on a cell generates both DblClick and MOUSE events (!)
> > >
> > > A single click on a cell generates a Mouse Down + Mouse UP.
> > > A double click generates a Mouse Down and 2 x Mouse UP. (I'm guessing
> > > the second "DOWN" becomes the DblClick)
> > >
> > > So, if I don't get associated mouse commands, it must be a double click
> > > on a header ... :-)
> > >
> > > Now to code it ... :)
> > >
> > > Gareth.
> > >
> > > On Fri, 2007-05-04 at 11:03 +0200, ron wrote:
> > > > On Friday 04 May 2007 10:11, Gareth Bult wrote:
> > > > > Yup, this is the issue I have .. it can be made to work "mostly" ..
> > > > >
> > > > > However, writing applications that work "mostly" doesn't really do
> > > > > it for me ... :(
> > > > >
> > > > > My solution for now is to use a keyboard event rather than a double
> > > > > click ...
> > > > > If anyone has a working calculation I'm all ears ... :)
> > > > >
> > > > > Gareth.
> > > >
> > > > This routine checks if the mouse x/y is above a cell and not in the
> > > > space below/right of it
> > > >
> > > > ' waiting for updated gambas, function is add on my request
> > > > PUBLIC FUNCTION hGrid at ...1692...(x AS Integer, Y AS Integer) AS Boolean
> > > > ' returns true if out range
> > > >   DIM gx, gy AS Integer
> > > >   DIM gc, gr AS Integer
> > > >   gx = 0
> > > >   gy = 0
> > > >   gc = 0
> > > >   gr = 0
> > > >   WITH hGrid
> > > >     gx = .Columns[0].Width
> > > >     WHILE x > gx
> > > >       INC gc
> > > >       IF gc > (.Columns.Count - 1) THEN RETURN TRUE
> > > >       gx += .Columns[gc].Width
> > > >     WEND
> > > >     gy = .rows[0].Height
> > > >     WHILE y > gy
> > > >       INC gr
> > > >       IF gr > (.rows.Count - 1) THEN RETURN TRUE
> > > >       gy += .rows[gr].Height
> > > >     WEND
> > > >     .Column = gc
> > > >     .Row = gr
> > > >   END WITH
> > > > END
> > > >
> > > >
> > > > As mentioned the GridVie.Find is implement and here as private
> > > > subroutine 'hGrid at ...1692...' hFrid is the handle for the GridView control.
> > > >
> > > > The calculation is here done.
> > > > In fact I set the .Row and .Column properties so after a call the
> > > > return boolean tells you if it is a valid hit or not.
> > > > When valid the GridView.Row and GridView.Column are set correct.
> > > >
> > > > -----------------
> > > >
> > > > Here I did use the service
> > > > grdFields is the name of the GridView and the hGrid handle of it
> > > > GridCtrlHide routine did hide the overlay controls for editing.
> > > > GridCtrlShow routine shows the appropriate control for the .Row
> > > >
> > > > The Gridview is used with on the row the value/properties of a field
> > > > in database table. Every row has his own control as
> > > > textbox/listbox/combobox/checkbox Every column is the representation
> > > > of a field.
> > > > The result is transformed to a MySQL query
> > > > Code is never been clean up of remarks etc.(shame to me)
> > > >
> > > >
> > > > PUBLIC SUB grdFields_MouseDown()
> > > > 'PRINT "grdFields_MouseDown:"; grdFields.Row; "/"; grdFields.Column
> > > > 'PRINT mouse.X
> > > >
> > > >   'if ctrl then save value if editing
> > > >   IF ctrTBX.Visible THEN ctrTBXSave
> > > >   GridCtrlHide
> > > >
> > > >   'and go to new position
> > > >  ' IF grdFields at ...1692...(mouse.x, mouse.y) THEN RETURN
> > > > ' GridCtrlShow(grdFields.Row, grdFields.Column)
> > > > END
> > > >
> > > > PUBLIC SUB grdFields_MouseMove()
> > > >   IF mouse.Left THEN
> > > > 'PRINT "grdFields_MouseMove"
> > > >
> > > >     'check in gridcell
> > > >     IF ME.grdFields at ...1692...(mouse.X, mouse.Y) THEN RETURN
> > > >    ' IF ME.grdFields.Find(mouse.X, mouse.Y) THEN RETURN
> > > >     grd.CtrlHide
> > > >     Drag.Icon = picture["img/16/gambas.png"]
> > > >     drag(grdFields, MIME_TYPE_GRID)
> > > >   END IF
> > > > END
> > > >
> > > > PUBLIC SUB grdFields_MouseUp()
> > > > DIM vVal AS Variant
> > > > 'PRINT "grdFields_MouseUp"; grdFields.Row; "/"; grdFields.Column
> > > >
> > > >   GridCtrlHide
> > > >
> > > >   IF grdFields at ...1692...(mouse.x, mouse.y) THEN RETURN
> > > >
> > > >   IF grdFields.row = grd.GRDVIS THEN
> > > >     ' row/column for write data in grid
> > > >     grdFields.Tag = [grdFields.Row, grdFields.Column]
> > > >     vVal = IIf(UCase(grdFields[grdFields.Row, grdFields.Column].Text)
> > > > = "YES", "No", "Yes") GridWrite(vVal)
> > > >   ELSE
> > > >     GridCtrlShow(grdFields.Row, grdFields.Column)
> > > >   ENDIF
> > > >
> > > > END
> > > >
> > > > -----
> > > >
> > > > Ron
> > > >
> > > >
> > > > ---------------------------------------------------------------------
> > > >-- -- This SF.net email is sponsored by DB2 Express
> > > > Download DB2 Express C - the FREE version of DB2 express and take
> > > > control of your XML. No limits. Just data. Click to get it now.
> > > > http://sourceforge.net/powerbar/db2/
> > > > _______________________________________________
> > > > Gambas-user mailing list
> > > > Gambas-user at lists.sourceforge.net
> > > > https://lists.sourceforge.net/lists/listinfo/gambas-user
> > >
> > > -----------------------------------------------------------------------
> > >-- This SF.net email is sponsored by DB2 Express
> > > Download DB2 Express C - the FREE version of DB2 express and take
> > > control of your XML. No limits. Just data. Click to get it now.
> > > http://sourceforge.net/powerbar/db2/
> > > _______________________________________________ Gambas-user mailing
> > > list Gambas-user at lists.sourceforge.net
> > > https://lists.sourceforge.net/lists/listinfo/gambas-user
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Gambas-user mailing list
Gambas-user at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


-- 
Gareth Bult, Encryptec Limited
Tel: 0845 25 77033, FWD: 753977, Mob: 07891 389657
Email: gareth at ...1689...

Statements made are at all times subject to Encryptec's Terms and Conditions of Business, which are available upon request.





More information about the User mailing list