Jump to content

unidbgrid weboptions


jahlxx

Recommended Posts

Hi,

 

For now quick (rough) workaround, try:

 

For example for "hide":

procedure TMainForm.UniButton1Click(Sender: TObject);
var
  DBGridJSName: string;
  PageSize, RecordCount: Integer;
  JSCode: string;
begin
  DBGridJSName := UniDBGrid1.JSName;
  RecordCount := UniDBGrid1.DataSource.DataSet.RecordCount;
  PageSize := RecordCount;

  UniDBGrid1.WebOptions.PageSize := PageSize;

  JSCode := DBGridJSName + '.getStore().pageSize=' + IntToStr(PageSize) + ';';
  if RecordCount > PageSize then
    JSCode := JSCode + DBGridJSName + '.pagingBar.show();'
  else
    JSCode := JSCode + DBGridJSName + '.pagingBar.hide();';

  JSCode := JSCode + DBGridJSName + '.getStore().load();';
  UniSession.AddJS(JSCode);
end;

for "show":

procedure TMainForm.UniButton2Click(Sender: TObject);
var
  DBGridJSName: string;
  PageSize, RecordCount: Integer;
  JSCode: string;
begin
  DBGridJSName := UniDBGrid1.JSName;
  RecordCount := 25;
  ...
end;

Best regards.

Link to comment
Share on other sites

Can you write full code for show?


procedure TMainForm.UniButton2Click(Sender: TObject);
var
  DBGridJSName: string;
  PageSize, RecordCount: Integer;
  JSCode: string;
begin
  DBGridJSName := UniDBGrid1.JSName;
  RecordCount := 25;
  PageSize := RecordCount;

  UniDBGrid1.WebOptions.PageSize := PageSize;

  JSCode := DBGridJSName + '.getStore().pageSize=' + IntToStr(PageSize) + ';';
  if RecordCount > PageSize then
    JSCode := JSCode + DBGridJSName + '.pagingBar.show();'
  else
    JSCode := JSCode + DBGridJSName + '.pagingBar.hide();';

  JSCode := JSCode + DBGridJSName + '.getStore().load();';
  UniSession.AddJS(JSCode);
end;
Link to comment
Share on other sites

  • 3 years later...

I know this is a really old topic, but I need to inform you that current solutions has problems. In one of my applications I am using a uniDBGrid to visualize different DB tables. Based on the above examples I tried to assign different page sizes based on the selected table.

Therefore I used this modified routine:

procedure TuDBFrame.SetPageSize(PageSize : integer);
var
  DBGridJSName: string;
  RecordCount: Integer;
  JSCode: string;
  st : TDataSetState;
begin
  DBGridJSName := UniDBGrid.JSName;
  st := UniDBGrid.DataSource.DataSet.State;
  if st in [dsInactive] then
    UniDBGrid.DataSource.DataSet.Open;
  RecordCount := UniDBGrid.DataSource.DataSet.RecordCount;
  UniDBGrid.WebOptions.PageSize := PageSize;

  JSCode := DBGridJSName + '.getStore().pageSize=' + IntToStr(PageSize) + ';';
  if RecordCount > PageSize then
    JSCode := JSCode + DBGridJSName + '.pagingBar.show();'
  else
    JSCode := JSCode + DBGridJSName + '.pagingBar.hide();';

  JSCode := JSCode + DBGridJSName + '.getStore().load();';
  UniSession.AddJS(JSCode);
end;

If I call this routine the first time for e.g. table A with a PageSize of 50 records and later for a different table B with a PageSize of 100 only the first 50 records of table B are listed in the dbgrid on the first page, i.e. 50 records are lost on the first page! When switching to the second page, this starts with record number 101 (which is in line with the changed page size).

I guess that the first call changes also some unknown but important JS variable, which later will not get changed anymore and leads to this unwanted effect.

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