1 (edited by sonixax 2019-09-14 11:41:16)

Topic: New Grid functins!

Hi everyone,
This new grid functions to add, edit and delete are awesome!
but the row on the top is some sort of ugly smile
these are my bunch of questions smile))

1 - How can I add + icon on first of the add row to let users knowing here designed to add new records?

2 - Grid will show calculated field text for, calculated database tables! how can I remove that text and replace it with something else?! as example some colors or icons!

3- I have two columns input and output! both of them are currency but cannot have amount at the same time (logically) by using normal method I can write very simple script to set input field to 0 if output have value and set output to 0 if input have value! how can I do the same for grid?!

4- How can I switch between new input columns with tab?! its easier to add big_smile

5- How can I format date time picker in grid? currently its on MM/dd/YYYY I want it as dd.MM.YYYY (Europian Version)

6- and lastly, I just have a search button there to search between records. but I don't know how can I restart grid to its original state! just tried dbUpdate, Refresh and Clear but not working!

Thanks a lot and have a lovely day

Re: New Grid functins!

any idea?!

Re: New Grid functins!

Hello.


1. You can't add icon to the top row, but you can do it more logical, place button with icon "Add" near with top row.

procedure Form1_TableGrid1_OnChange (Sender: TObject);
begin
    Form1.TableGrid1.AllowCreate := False;
end;

procedure Form1_Button1_OnClick (Sender: TObject; var Cancel: boolean);
begin
    Form1.TableGrid1.AllowCreate := not Form1.TableGrid1.AllowCreate;
    if Form1.TableGrid1.AllowCreate then Form1.Button1.dbIconName := 'Cancel' else Form1.Button1.dbIconName := 'New';
end;

2. You can change text, but not color.

procedure Form1_TableGrid1_OnChange (Sender: TObject);
begin
     Form1.TableGrid1.Columns[0].InputCaption := 'your text';
end;

3.

procedure Form1_TableGrid1_OnInputAccept (Sender: TObject; var Accept: Boolean);
begin
  if (Form1.TableGrid1.Columns[1].InputValue <> '') and (Form1.TableGrid1.Columns[1].InputValue <> '0') then Form1.TableGrid1.Columns[0].InputValue := '0';
  if (Form1.TableGrid1.Columns[0].InputValue <> '') and (Form1.TableGrid1.Columns[0].InputValue <> '0') then Form1.TableGrid1.Columns[1].InputValue := '0';
end;

4. It doesn't support.


5. Date formatting is determined by the user's regional settings, but you can change it:

procedure Form1_TableGrid1_OnChange (Sender: TObject);
begin
   TNxDateColumn(Form1.TableGrid1.Columns[0).FormatMask :='dd.mm.yyyy';
end;

The following formatting character strings can be used in the Formatting string:

y     = Year last 2 digits
yy     = Year last 2 digits
yyyy     = Year as 4 digits
m     = Month number no-leading 0
mm     = Month number as 2 digits
mmm     = Month using ShortDayNames (Jan)
mmmm     = Month using LongDayNames (January)
d     = Day number no-leading 0
dd     = Day number as 2 digits
ddd     = Day using ShortDayNames (Sun)
dddd     = Day using LongDayNames  (Sunday)
ddddd     = Day in ShortDateFormat
dddddd     = Day in LongDateFormat
     
c     = Use ShortDateFormat + LongTimeFormat
h     = Hour number no-leading 0
hh     = Hour number as 2 digits
n    = Minute number no-leading 0
nn     = Minute number as 2 digits
s     = Second number no-leading 0
ss     = Second number as 2 digits
z    = Milli-sec number no-leading 0s
zzz     = Milli-sec number as 3 digits
t     = Use ShortTimeFormat
tt     = Use LongTimeFormat
     
am/pm     = Use after h : gives 12 hours + am/pm
a/p     = Use after h : gives 12 hours + a/p
ampm     = As a/p but TimeAMString,TimePMString
/     = Substituted by DateSeparator value
:    = Substituted by TimeSeparator value


6. Just clear all components which used for searching, then call method dbUpdate
Example

procedure Form1_Button1_OnClick (Sender: TObject; var Cancel: boolean);
begin
    Form1.edFirstName.Clear;
    Form1.cbGroup.dbItemID := -1;
    Form1.DateTimePicker1.Checked := False;
    Form1.TableGrid1.dbUpdate;
end;
Dmitry.

Re: New Grid functins!

Hi Sonixax,
On Point 4, as Dmitry says, it's not possible to use 'tab' to move from one field to another.
However, if you tick 'goarrowkeyexitediting' (see attached screenshot), you can use the arrow keys to move from one input column to another.
This also works when you are editing cells in the grid, so you can go up, down, left and right; so it's probably more flexible than 'tab'.
Regards,
Derek.

Post's attachments

Attachment icon screenshot1.jpg 264.5 kb, 155 downloads since 2019-09-17