1 (edited by mathmathou 2017-04-27 00:40:24)

Topic: [Solved] Delete Col and value

Hello Dmitry and all MVD fans,


Wether by script or with SQLQuery button, we have the ability to hide one or more columns issued from the query by using the reserved word 'delete_col'.


When delete_col is used on the ID of the record, the tablegrid does not display the ID in the row, but

Form1.tablegrid.dbItemID

still refers to the ID and can be used for another query or function.


My question :

If on a SQLQuery Button I have this query :

SELECT
artist.id,
artist.artist_name,
artist_asset.auto
FROM
artist_asset
INNER JOIN artist ON artist_asset.id_artist = artist.id
WHERE artist_asset.id_asset = {edAID} 
ORDER BY upper(artist_name) ASC  

and this setting for the column names in the Tablegrid :

delete_col,Artist Name,delete_col

how can I still get the value of the "auto" field in the tablegrid (on cell click for example...) ?


Thanks in advance


Mathias

I'm a very good housekeeper !
Each time I get a divorce, I keep the house

Zaza Gabor

Re: [Solved] Delete Col and value

Hello.


When you use reserved word 'delete_col', column will be deleted, thus you can't read value of this column.


But you can make SQL query to get this value from database.

procedure Form1_TableGrid1_OnCellClick (Sender: string; ACol, ARow: Integer);
var
    sValue: string;
begin
    sValue := SQLExecute('SELECT auto FROM artist_asset WHERE id='+Form1.TableGrid1.sqlValue);
end;


another way, hide a colum using script, in this way you still can read a value from hided the column.

procedure Form1_TableGrid1_OnChange (Sender: string);
begin
    Form1.TableGrid1.Columns[2].Visible := False;
end;

procedure Form1_TableGrid1_OnCellClick (Sender: string; ACol, ARow: Integer);
var
    sValue: string;
begin
    sValue := Form1.TableGrid1.Cells[2,ARow];
end;
Dmitry.

Re: [Solved] Delete Col and value

Hello Dmitry,


I love the second method, the first one needing a SQLQuery.


Thank you sir, for your fast and perfect answer ! smile


Cheers


Math

I'm a very good housekeeper !
Each time I get a divorce, I keep the house

Zaza Gabor