Jump to content

Recommended Posts

Posted

How to make DBGRID can scroll up or down automatically to approach the searched data as the usual dbgrid in desktop version?

I mean when the  data is being searched using findkey / locate / findnearest, the "pointer" on dbgrid can really focus on the searched data record and the scrollbar can up an down automatically following the result.

 

Best Regards.

 

 

 

Posted

Hi,

 

While, maybe it will help:

 

for example:

...
procedure TMainForm.UniButton1Click(Sender: TObject);
var
  gridJSName: string;
begin
  gridJSName := UniDBGrid1.JSName;
  if ClientDataSet1.Locate('EmpNo', UniEdit3.Text, [loPartialKey, loCaseInsensitive]) then begin
    if UniDBGrid1.WebOptions.Paged then 
      UniSession.AddJS(gridJSName + '.getView().select('+ gridJSName +'.store.findRecord(''0'',' +UniEdit3.Text+')); '+ gridJSName +'.getView().focusRow('+IntToStr((ClientDataSet1.RecNo-1)mod UniDBGrid1.WebOptions.PageSize)+');')
    else
      UniSession.AddJS(gridJSName + '.getView().select('+ gridJSName +'.store.findRecord(''0'',' +UniEdit3.Text+')); '+ gridJSName +'.getView().focusRow('+IntToStr(ClientDataSet1.RecNo-1)+');');
  end;
end;
...

Best regards.

Posted

Hi,

 

I've already tried your method, and the result is not perfect yet (some is working, but some is not (yet)).

 

1. Using "ClientDataset" with biolife.cds database --> Success

 

2. Using "ADOTABLE" with MS.ACCESS database --> Success

 

3. Using either "ADOTABLE" nor "FIREDAC" with MSSQLSERVER database --> not working and there're errors like these :

 

_rsov_(O5A,0);O62.getView().select(O62.store.findRecord('0',U001)); O62.getView().focusRow(13);O66.loadPage(2,{params:{start:25,limit:25,options:1}});  

 

 

 

I've attached the source code:

 

For Table on MSSQLSERVER just made them with the script below :

 

 

CREATE TABLE [dbo].[MHCustomer](
    [Kode] [varchar](10) NOT NULL,
    [Nama] [varchar](100) NULL,
    [Kelompok] [varchar](2) NULL,
    [KodeCOA] [varchar](50) NULL,
    [userId] [varchar](25) NULL,
    [TglInput] [datetime] NULL,
 CONSTRAINT [PK_MHCustomer] PRIMARY KEY CLUSTERED
(
    [Kode] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

 

 

Best Regards,

post-2205-0-80663600-1422360016_thumb.jpg

Project4.zip

Posted

Error: store.findRecord('0',U001)

 

 

Info:

store.findRecord("fieldIndex", "searchValue");

Corrected:

...
procedure TMainForm.UniButton1Click(Sender: TObject);
var
  gridJSName: string;
begin
  gridJSName := UniDBGrid1.JSName;
  if ClientDataSet1.Locate('EmpNo', UniEdit3.Text, [loPartialKey, loCaseInsensitive]) then begin
    if UniDBGrid1.WebOptions.Paged then 
      UniSession.AddJS(gridJSName + '.getView().select('+ gridJSName +'.store.findRecord("0","' +UniEdit3.Text+'")); '+ gridJSName +'.getView().focusRow('+IntToStr((ClientDataSet1.RecNo-1)mod UniDBGrid1.WebOptions.PageSize)+');')
    else
      UniSession.AddJS(gridJSName + '.getView().select('+ gridJSName +'.store.findRecord("0","' +UniEdit3.Text+'")); '+ gridJSName +'.getView().focusRow('+IntToStr(ClientDataSet1.RecNo-1)+');');
  end;
end;
...
  • Upvote 1
×
×
  • Create New...