1

(5 replies, posted in Script)

Problem solved, thanks derek and ehwagner.

Vladimir

2

(5 replies, posted in Script)

amadeus.sync wrote:
derek wrote:

Hi,
The easiest (and most efficient) way would be to use a calculated field (see attached).
Derek.

This will get job done. Thanks again for your time.

Vladimir

Hey my man, after I tested this, problem in my case is that my 'quantiy' is calculated field. Is there another solution?

Thanks.

3

(5 replies, posted in Script)

derek wrote:

Hi,
The easiest (and most efficient) way would be to use a calculated field (see attached).
Derek.

This will get job done. Thanks again for your time.

Vladimir

4

(5 replies, posted in Script)

I'm trying to format cells individualy. What I need is how to format each cell in same column differently. Example:

frmForm1.TableGrid1.cell[6,1] is integer and I need to format like 0 + km; (integer + text1)
frmForm1.TableGrid1.cell[6,2] is integer and I need to format like 0 + l; (integer + text2)
frmForm1.TableGrid1.cell[6,3] is integer and I need to format like 0 + kg; (integer + text3)

It's not possible to do it with currency field or with TNxNumberColumn(Form1.TableGrid1.Columns[6]).FormatMask := '... '; because each cell format need to be different. Also, I created column 7 with cuurency (string: km, l, kg) but I don't know syntax to put together  integer in cell[6,y] + string in cell[7,y] so it can look like this in same cell, example:  cell[6,1] 15 km or cell[6,2] 15 l or cell[6,3] 15 kg. If this is possible, later I can hide column7.

Thanks in advance,

Vladimir

5

(7 replies, posted in General)

derek wrote:

Hope this clarifies things,
Derek.

Yes, you are right, my mistake.

Thanks for help and for your time.

6

(7 replies, posted in General)

derek wrote:

Hi Vladimir,
Going through your points,
2.  hiding elements depending on user roles works okay for me ('admin' user over-rides any 'role' that is assigned).
3.  see attached for a way to open and view the contents of the folder that is specified as the 'copy to' in the 'Link Folder' option
4.  not sure what you mean by this - can you explain it in more detail?
5.  see attached - you totally disable 'doubleclick' to select a record from the tablegrid and have to use one of the 'show record' buttons (3 in my example, each one selecting a different form and different fields).
Derek.

Hi Derek,

Thanks for quick answers
.
2. Something's wrong with my Db. I have created admin = admin, Derek - role = editor and Vladimir - role=  user.  Then i set up 'Button roles : set to User, behavior set to rbbHide', When I login as Vladimir (user) I can see button, but when I login as Derek (editor) button is hidden. It seems like somehow program is mixing users and roles... I'm not sure what is happening.

4. I wanted to disable all mouse actions on TableGrid except vertical scroll when there is a lot of data in table. I'm not sure if this is possible.

And again, thank you.

Vladimir

7

(7 replies, posted in General)

1. Recently I discovered this great piece of software. My question is, if I buy 'SINGLE USER Free Minor Updates' licence now, is it possible to upgrade to 'SINGLE USER Life Time License' later on? Where I live money is always tight, so it would be great if upgrade is possible. I'm still learning, so no commercial use for me in near future so 'Free Minor Updates' licence would be enough while I'm learning stuff.


2. My main problem is that roles behavior doesn't work. What I did is Project > Roles > Enable Role-based access > Create role. After that,
I created new Active - non Admin user with assinged role but when I try to hide or disable element for that role, nothing happens. Login works fine. What  I'm doing wrong?
What is strange, when I started to use MVDB (month ago - trial licence), i remmember it worked fine. You can see attached simple project (one form, one button) in which roles behavior don't work for me.


3. Can someone help me with snippet syntax for 'ButtonOnClick' to open folder (folder path stored in database field with 'DBFile > Link folder).


4. Is it possible, when 'TableGrid Enabled = False', to enable only 'Select row' and 'Vertical scroll' on mouse over?


5. On my main form, I have 'TableGrid1' and 5 Buttons ('Show record' from 'TableGrid1' in 5 different forms). If I double click on row in TableGrid1, it opens all 5 button assigned  'Show record' forms.  Is it possible to disable this to happen?


And again, thanks everybody for helping me and sorry if my english is not perfect, it's not my native language.

Greetings, Vladimir.


Edit1: Now, 1 our later, it works ok again.... Sometime it works, sometime dont.

8

(7 replies, posted in General)

derek wrote:

Hi,
If I understand your project correctly, your calculated field to show the max(stanje_km_sata) should be in table 'vozila' and not in table 'servis'.
It's also perhaps slightly more efficient to use the servis.id_service_types = 1 rather than to read the service_types table and select where type = 'Редован сервис'.
Regards,
Derek.

Yea, that's it. You are great, thank you very much for help.

9

(7 replies, posted in General)

derek wrote:

Hello Amadeus,
I'm not sure if this is the sort of thing you are after (please see the attached).
Rather than change your tablegrid, I have just used a second 'summary' grid and put a number of calculated fields in there.
Because it is a 'summary', I am displaying columns to 0 decimal places so there may be slight rounding differences (but you can always amend the calculations to give better accuracy if you need).
Hope this helps,
Derek.

Hi Derek,

I have one more problem.  I need calculated field which will take MAX from filed 'stanje_km_sata' - table 'servis' but only if field 'options' from table 'service_types' = 'Редован сервис'.  I tried somethink like this but it's not correct:

(select max(stanje_km_sata) from servis where servis.id_vozila = vozila.id and servis.id_service_types like 'Редован сервис')  

I'll attach project and thanks in advance.

10

(7 replies, posted in General)

derek wrote:

Hello Amadeus,
I'm not sure if this is the sort of thing you are after (please see the attached).
Rather than change your tablegrid, I have just used a second 'summary' grid and put a number of calculated fields in there.
Because it is a 'summary', I am displaying columns to 0 decimal places so there may be slight rounding differences (but you can always amend the calculations to give better accuracy if you need).
Hope this helps,
Derek.

This is better than I asked for. Now I have examples for all calculations I may need. Great!

Thank you very much.

11

(7 replies, posted in General)

Here it is. It' in Serbian, pls ask if there is some explanation needed. You'll see I tried in Form1, colum cumulative avg, but that's not what I wanted.

12

(7 replies, posted in General)

Hello everybody.

I'm coding noob, still learning. I was searching forums but can't make it work. I'm trying to make vehicle tracking database.
I have two tables: vehicles and fuel_fillings. In table fuel_fillings there is relationship field with table vehicles. One of the fields also is monthly_qty of fuel filled. What I want to to do is, for example, in from1 table grid1 I want to show summary for all vehicles where one of the column is cumulative avg fuel filings (vehicle1 - fuel qty month1 + month2..../number of months) - Cumulative AVG for all fuel qty  per vehicle. Basically what I'm trying to do is to show footer(AVG) for field monthly_qty for each vehicle in summary tablegrid1.
Is it possible to do it with calculated field or some other way?
Also, it would be great if someone know  if there is some link where I can learn about tables data manipulation.

Thanks all of you for helping me.

Stay well

13

(10 replies, posted in General)

DriveSoft wrote:

You should use event OnResize of the TableGrid component, not form.


instead

procedure frmReview_OnResize (Sender: TObject; Action: string);

you should use

procedure frmReview_TableGrid1_OnResize (Sender: TObject);

Yea, that works. Thanks.

14

(10 replies, posted in General)

derek wrote:

Hi,
Can you upload your project (zipped and without the executable) and someone can take a look for you?
Derek.


There it is.
Thanks for helping.

15

(10 replies, posted in General)

DriveSoft wrote:

Example for three columns: 50+30+20=100%

procedure Form1_TableGrid1_OnResize (Sender: TObject);
begin
    Form1.TableGrid1.Columns[0].Width := Trunc(Form1.TableGrid1.ClientWidth * (50 / 100)); // 50%
    Form1.TableGrid1.Columns[1].Width := Trunc(Form1.TableGrid1.ClientWidth * (30 / 100)); // 30%
    Form1.TableGrid1.Columns[2].Width := Trunc(Form1.TableGrid1.ClientWidth * (20 / 100)); // 20%
end;

For some reason, after implementing this script (which works fine) I have another problem. On my main form (frmHome)  I have button1 to show Form1 with TableGrid1 (form and grid in script). When I click button1, frmHome minimizes and it's impossiblle to restore it. I tried to solve problem adding script:

procedureForm1_OnClose (Sender: String; Action: string);
begin
    frmHome.Show;
end;

but after closing Form1, frmHome is still minimized and can't be restored.

Sorry for so many questions, I'm still learning and thanks for helping me.

16

(10 replies, posted in General)

DriveSoft wrote:

Example for three columns: 50+30+20=100%

procedure Form1_TableGrid1_OnResize (Sender: TObject);
begin
    Form1.TableGrid1.Columns[0].Width := Trunc(Form1.TableGrid1.ClientWidth * (50 / 100)); // 50%
    Form1.TableGrid1.Columns[1].Width := Trunc(Form1.TableGrid1.ClientWidth * (30 / 100)); // 30%
    Form1.TableGrid1.Columns[2].Width := Trunc(Form1.TableGrid1.ClientWidth * (20 / 100)); // 20%
end;


Perfect !
Thanks again.

17

(10 replies, posted in General)

DriveSoft wrote:

Hello.


You can do it using this simple script

procedure Form1_TableGrid1_OnResize (Sender: TObject);
var
    i, c: integer;
begin
    c := Form1.TableGrid1.Columns.Count-1;
    for i := 0 to c do
    begin
        Form1.TableGrid1.Columns[i].Width := Form1.TableGrid1.ClientWidth div Form1.TableGrid1.Columns.Count;
    end;
end;

Edit 2: corrected one line of code:

frmPreglediPretraga.TableGrid1.Columns[i].Width := frmPreglediPretraga.TableGrid1.ClientWidth div c ;

18

(10 replies, posted in General)

Thanks man, works perfectly.

Edit: Is it possible to keep columns width proportions? With this script, all columns width are same size.

Thanks again Dmitry.

19

(10 replies, posted in General)

Hello MVDers,

Just quick question... I can't find option for resizing table grid columns width when resizing window. I set up anchors for table grid to ALL but I would like to auto resize collumns width when resizing window.

Thanks in advance