Jump to content

[uniGUI 1.90.0 build 1568] How to set dynamically column filtering editor


bruno65

Recommended Posts

The uniDBGrid doesn't have design columns. So i want to set dynamically column filtering editor :

procedure TMainForm.UniDBGrid2BeforeLoad(Sender: TUniCustomDBGrid);
var
  LGrid: TUniDBGrid;
begin
  LGrid := TUniDBGrid(Sender);
  LGrid.Columns[1].Filtering.Editor := UniEdit3;
  LGrid.Columns[1].Filtering.Enabled := True;
....
  LGrid.Options := LGrid.Options + [dgFilterClearButton];
end;

Editors don't appear in the top of the columns :

image.png.ab6acd2da1e546112ae23c1c0fe74cef.png

Link to comment
Share on other sites

  • bruno65 changed the title to [uniGUI 1.90.0 build 1568] How to set dynamically column filtering editor

i try this 

JSInterface.JSCall('setEditor', [UniEdit3.JSControl], LGrid.Columns[1].JSColumn); 
// instead of LGrid.Columns[1].Filtering.Editor := UniEdit3;

but no editor again

Link to comment
Share on other sites

i try this

type
  TExUniCustomDBGrid = class (TUniCustomDBGrid);
...
procedure TMainForm.btFilterClick(Sender: TObject);
begin
  FShowFilter := not FShowFilter;
  ShowFilterColumns(FShowFilter);
  if FShowFilter then
    btFilter.Caption := 'Masquer filtres'
  else
    btFilter.Caption := 'Afficher filtres';
end;

procedure TMainForm.ShowFilterColumns(AShowFilter: Boolean);
begin
  UniDBGrid2.Columns[1].Filtering.Editor := UniEdit3;
  UniDBGrid2.Columns[4].Filtering.Editor := UniDateTimePicker3;
  UniDBGrid2.Columns[5].Filtering.Editor := UniFormattedNumberEdit2;

  UniDBGrid2.Columns[1].Filtering.Enabled := AShowFilter;
  UniDBGrid2.Columns[4].Filtering.Enabled := AShowFilter;
  UniDBGrid2.Columns[5].Filtering.Enabled := AShowFilter;

  if AShowFilter then
    UniDBGrid2.Options := UniDBGrid2.Options + [dgFilterClearButton]
  else
    UniDBGrid2.Options := UniDBGrid2.Options - [dgFilterClearButton];

  TExUniCustomDBGrid(UniDBGrid2).DoConfigureJSColumns(UniDBGrid2.DataSource.DataSet);
end;

clear button ok but no editor filters again ! Why is it not intuitive and simple to do basic things like this ?image.png.bb15fb42d9cc22b2b8f47b5a5f1071bb.png

Link to comment
Share on other sites

After looking deeper in uniGUI code, successive calls seem to be :

1-procedure TUniCustomDBGrid.DoConfigureJSColumns(ADataSet: TDataSet);
2-procedure TUniCustomDBGrid.CreateJSColumns(JSColumns: TUniJSGridColumns; ADataSet: TDataSet);
3-function TUniCustomDBGrid.CreateJSColumn(JSColumns: TUniJSGridColumns; Column: TUniBaseDBGridColumn; ADataSet: TDataSet = nil): TJSGridColumn;
4-procedure TUniCustomDBGrid.JSConfigColumn(Column: TUniBaseDBGridColumn; JSCol: TJSGridColumn; Fld : TField);
5-procedure TUniCustomDBGridColumn.InitFilter(C: TJSObject; Fld: TField);

Especially in the end of procedure TUniCustomDBGrid.JSConfigColumn()

 

...
  if JSCol.HasEditor then
    TUniCustomDBGridColumn(Column).InitEditor(JSCol, Fld, (not AllowEdit) and RowEditor); 

  if TUniCustomDBGridColumn(Column).FFiltering.Enabled then
    TUniCustomDBGridColumn(Column).InitFilter(JSCol, Fld);

And in the procedure TUniCustomDBGridColumn.InitFilter()

...
	FEdit := FFiltering.Editor as TUniFormControl;
...
      with FGrid do
      begin
        if not FEdit.IsMultiComponent then
          JSAddListener('afterrender',
            JSFunction('s', 's.el.on("click",function(){'#1'.fedit.focus()})'),
          C);
        JSConfig('items', [JSArray([FEdit.JSControl])], C);
        JSConfig('fedit', [FEdit.JSControl], C);
        JSAssign('isFilter', [True], FEdit.JSControl);
        JSConfig('padding', ['0 0 0 5'], C);
      end;
Link to comment
Share on other sites

24 minutes ago, bruno65 said:

reproduce the bug is not trivial. It seems to occur "randomly" after clicking on the 2 buttons but it could be happened quickly

The button can be disabled until the next click...

Link to comment
Share on other sites

the bug can happen whatever the speed of clicking on the buttons. There is really no effect to generate the bug

Beside we are interesting of how to disable a button until the next click for other use cases : can you share us the code ?

Link to comment
Share on other sites

by completing the previously attached project I can generate this bug again. Use-case :

1 - modify one or more cells in one or more records

2- click the button "Sauver" for saving data (and reload it)

Redo the 2 steps above one more (or several) time again... and you'll get the error at step 1 and any cell could not be modified. The application is OUT

image.thumb.png.8189e5e99fffedc118cdd3cfa7995dec.png

 

testUniDBGridFilterAndSort.zip

Link to comment
Share on other sites

On 3/22/2024 at 7:04 PM, bruno65 said:

Any solution to fix bugs in the last attached project ?

I have analyzed for this button: btFilter

 

On 3/12/2024 at 3:15 PM, Sherzod said:

The button can be disabled until the next click...

I have already noted this before, try...

 

btFilter.ClientEvents.ExtEvents ->

function click(sender, e, eOpts)
{
    sender.showMask('Please wait...');
}

 

Link to comment
Share on other sites

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...