Jump to content

Changing dbgrid paging properties at runtime


estrify

Recommended Posts

Hi,

 

I have a paged dbgrid that has akRight and akBottom anchors. At runtime, when I change PageSize of the grid to adapt its content to the available space after a form resizing, the paging bar does not update its initial parameters. How can I update them?. Sure I am missing something trivial but if not, is there a workaround to achieve this result??

 

Thanks in advance...

 

Link to comment
Share on other sites

Probably you need to call Refresh method of Grid.

 

Thanks for response. But by now, this is insufficient...

 

However, I have found a way to workaround this... Please, consider add the dynamic changing of the PageSize as a new feature... By now, here is how to achieve it:

dbgrd.WebOptions.PageSize:=iNewPageSize; /* for now this has no effect. Only to be "clean" */
UniSession.AddJS(
    dbgrd.JSName+'.getStore().pageSize='+IntToStr(iNewPageSize)+';'+
    dbgrd.JSName+'.getStore().load({params: { limit: '+IntToStr(iNewPageSize)+' }});'+
    dbgrd.JSName+'.getView().refresh();'
);

One more question: in UniDBGrid, is there a way to retrieve the total height of headers (considering grouping and so on) and the pager??

 

Regards,

 

 

  • Upvote 1
Link to comment
Share on other sites

Hi,

 

Also you can try to use this plugin for now

and I think this plugin can be added in future versions:

http://forums.unigui.com/index.php?/topic/4210-pagesize-extension-for-unidbgrid/

 

One more question: in UniDBGrid, is there a way to retrieve the total height of headers (considering grouping and so on) and the pager??

 

If I understand you correctly, you can get them something like this (on the client side):

MainForm.UniDBGrid1.pagingBar.getHeight();
MainForm.UniDBGrid1.headerCt.getHeight();

Best regards.

Link to comment
Share on other sites

Thanks for the answer...

 

The plugin is very useful but I need to adjust paging automatically to the available space exactly ... This is why I need the height of different components to calculate the number of lines to be displayed avoiding to show grid's vertical scroll bar... I have already achieved it... Thanks a lot..

 

Regards,

Link to comment
Share on other sites

  • 1 year later...

Hello everyones !

 

Is there a way to get 'UniDBgrid1.store.currentPage' by programmatically ?

 

For now the only solution I found is to make an ajaxRequest with this prop in order to access it in delphi ...

 

Thanks for your time ! (:

 

 

Edit: Okay I did not really think this through.. it very simple currentPage := Ceil((Recno * total nbr of page) / RecordCount) ... could you add a property "CurrentPage" as there is CurrRow, CurrCol .. ? :D

Link to comment
Share on other sites

Edit: Okay I did not really think this through.. it very simple currentPage := Ceil((Recno * total nbr of page) / RecordCount) ... could you add a property "CurrentPage" as there is CurrRow, CurrCol .. ? :D

 

Or something like that:

CurrPage = UniDBGrid1.DataSource.DataSet.RecNo div UniDBGrid1.WebOptions.PageSize + 1
Link to comment
Share on other sites

Yeah, the approach is even simpler ! ^^

 

What about setting the current page programmatically ?

 

In JS I've seen that UniSession.AddJS(UniDBGrid1.JSName+'.store.loadPage(1);'); is working, but maybe there is a way in delphi ? :3

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...