Jump to content

Create Group in dbgrid at runtime


anderson da silva

Recommended Posts

Hi,
I have a following Scene:
1. A uniDbGrid with no fields created
2. a TfdMemTable with no Field created
When I populate my TfdMemTable with fields and records, 
I would like to create a grouping in this uniDbGrid that 
received the information.
It does not generate an error, it creates an ordering but does not group.
How to solve? 
I've seen all the examples but in all of them the creation 
already has the grouping and in my case I still don't have a 
field created to be used in this creation.
Link to comment
Share on other sites

3 hours ago, anderson da silva said:

GroupRunTime.rar 33.18 kB · 2 downloads

Workaround:

1. 

procedure TMainForm.UniFormCreate(Sender: TObject);
begin
  with UniDBGrid1.JSInterface do
    JSConfig('features', [JSObject('ftype: "grouping"')])
end;

2. 

...
  UniComboBox1.Items.Clear;
  UniComboBox1.Items.Add('Pais');
  UniComboBox1.Items.Add('Estado');
  UniComboBox1.ItemIndex := 0;
  UniComboBox1.OnChange(UniComboBox1);  //<-------
...

3. 

procedure TMainForm.UniButton2Click(Sender: TObject);
begin
  If UniDBGrid1.Grouping.Enabled = False Then
    Begin
      UniButton2.Caption := 'Desagrupar';
      with UniDBGrid1 do
      begin
        Grouping.Enabled := True;
        JSInterface.JSCall('getStore().setConfig', [JSInterface.JSObject('groupField: "'+ Columns.ColumnFromFieldName(Grouping.FieldName).ColID.ToString +'"')]);
      end;
    End
    else
    Begin
      UniButton2.Caption := 'Agrupar';
      with UniDBGrid1 do
      begin
        Grouping.Enabled := False;
        JSInterface.JSCall('getStore().setConfig', [JSInterface.JSObject('groupField: null')]);
      end;
    End;
end;

 

Link to comment
Share on other sites

  • 1 month later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...