jahlxx Posted June 28, 2016 Posted June 28, 2016 Hi. Any way to set weboptions of a unidbgrid in runtime? I switch paged between true and false, but dont refresh the view. Tried with refresh, but refresh the content, not the aspect. Thanks. Quote
Sherzod Posted June 28, 2016 Posted June 28, 2016 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. Quote
Sherzod Posted June 28, 2016 Posted June 28, 2016 and most importantly, you should in design time: UniDBGrid1->WebOptions->Paged = True Quote
jahlxx Posted June 28, 2016 Author Posted June 28, 2016 Ok. Thanks. Can you write full code for show? Thanks. Quote
Sherzod Posted June 28, 2016 Posted June 28, 2016 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; Quote
Kattes Posted January 19, 2020 Posted January 19, 2020 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. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.