Topic: Change Grid cell text

Hi,
Is there anyway to change a grid cell text using Script?
Cannot find any property sad

Many thanks

Re: Change Grid cell text

Hi,
There are different ways to do this.
Which is best depends on what you're actually doing - updating a specific cell or any highlighted cell etc.
I'm guessing that you're wanting to both change the grid cell text AND save it rather than just changing it (otherwise there's little point LOL!).
Have a look at the attached as one option (enter your next text in the edit field and then click in the appropriate cell.

Post's attachments

Attachment icon change cell text.zip 483.24 kb, 267 downloads since 2022-09-04 

Re: Change Grid cell text

Wow,
Many Many Thanks

Re: Change Grid cell text

I have a question,
this

Main.TransGrid.Cells[9,i] := 'Nein';

return an error and said Nein is not integer!!!!!!
before update to v6 this one was ok but now its not working anymore sad

How can I fix it?

Many thanks

Re: Change Grid cell text

Hi Sonixax,
Works okay for me (Windows10 and MVD 6.5) - see attachment.
Maybe upload your project to see if there is something else going on.
Derek.

Post's attachments

Attachment icon sonixax.zip 484.41 kb, 179 downloads since 2022-10-31 

Re: Change Grid cell text

derek wrote:

Hi Sonixax,
Works okay for me (Windows10 and MVD 6.5) - see attachment.
Maybe upload your project to see if there is something else going on.
Derek.

Sure,
Attached you can find the project.
Many thanks

Post's attachments

Attachment icon Project.zip 473.46 kb, 182 downloads since 2022-10-31 

Re: Change Grid cell text

Hi,
I'd be tempted to use calculated fields to hold Ja and Nein for the 'checked' field and to hold Einnahme and Ausgabe for the 'type' field.and it makes the script a bit simpler.
Derek.

Post's attachments

Attachment icon sonixaxproject.zip 473.53 kb, 202 downloads since 2022-11-01 

8 (edited by sparrow 2022-11-01 07:52:21)

Re: Change Grid cell text

Hi Derek, Sonixax

Sonixax, In Derek's project
In Button12 please modify SQL Query


SELECT
"$autoinc"
,strftime('%d.%m.%Y', Ennahmeausgabe.datum)
,Ennahmeausgabe.belegnr
,kontakt.fullname
,(SELECT kontakt.fullname FROM kontakt WHERE id = id_kontakt1)
,Ennahmeausgabe.grund
,CASE WHEN Ennahmeausgabe.type = 0 THEN Ennahmeausgabe.amount ELSE Ennahmeausgabe.amount * -1 END
,CASE WHEN Ennahmeausgabe.type = 0 THEN Ennahmeausgabe.amount_dol ELSE Ennahmeausgabe.amount_dol * -1 END
,CASE WHEN Ennahmeausgabe.type = 0 THEN 'Einnahme' ELSE 'Ausgabe' END  
,CASE WHEN Ennahmeausgabe.checked = 0 THEN 'Nein' ELSE 'Ja' END
,Ennahmeausgabe.id
                                    
FROM Ennahmeausgabe

LEFT OUTER JOIN kontakt ON kontakt.id = Ennahmeausgabe.id_kontakt

WHERE

(CASE WHEN {ComboBox1} <> -1 then {ComboBox1} = id_kontakt else 1=1 end) OR
(CASE WHEN {ComboBox1} <> -1 then {ComboBox1} = id_kontakt1 else 1=1 end)

 ORDER by  Ennahmeausgabe.datum  asc

AND comment lines in the two place in the script

   //      Main.TransGrid.Cells[6,i] := '-'+Main.TransGrid.Cells[6,i];
   //      Main.TransGrid.Cells[7,i] := '-'+Main.TransGrid.Cells[7,i];

It remains to deal with the colors of the cells. I think that you will do it yourself.
But keep in mind that you have coloring in two places.
In the table event handler and in the Button12 button handler. They can interfere with each other))).


Have a look at this: http://myvisualdatabase.com/forum/viewtopic.php?id=5402

Re: Change Grid cell text

sonixax wrote:

I have a question,
this

Main.TransGrid.Cells[9,i] := 'Nein';

return an error and said Nein is not integer!!!!!!
before update to v6 this one was ok but now its not working anymore sad

How can I fix it?

Many thanks

You cannot write a text value to a Boolean field.
There are several solutions:
1. Add an empty text field to the query and then enter a text value into it.
2. Form the desired text directly in the SQL query using the CASE command  like Sparrow writing

Визуальное программирование: блог и телеграм-канал.

Re: Change Grid cell text

Sparrow, Derek, k245.
Many many thanks for your support smile
Everything now working perfectly, I just have another question which is need another topic.

Many thanks again.