art Posted April 29, 2025 Posted April 29, 2025 Hello! Is there a nearly proper way to set UniDBGrid WebOptions.PageSize depending on theme, font, grid header height etc. or get RowHeight from theme's css. I found a solution in the forum but it does not make a perfect solution: iPageSize:=Round((UniDBGrid.Height-80)/(21*23)*23); UniDBGrid.WebOptions.PageSize := iPageSize; UniSession.AddJS( UniDBGrid.JSName+'.getStore().pageSize='+IntToStr(iPageSize)+';'+ UniDBGrid.JSName+'.getStore().load({params: { limit: '+IntToStr(iPageSize)+' }});'+ UniDBGrid.JSName+'.getView().refresh();' ); Thanks in advance Quote
Sherzod Posted April 29, 2025 Posted April 29, 2025 Hello, Just to clarify: even if we dynamically calculate the row height, what would you consider to be the correct way to determine the PageSize? Should it exactly fit the visible height of the grid, or are you aiming for a visually balanced result depending on the theme and font? Quote
art Posted April 30, 2025 Author Posted April 30, 2025 17 hours ago, Sherzod said: Hello, Just to clarify: even if we dynamically calculate the row height, what would you consider to be the correct way to determine the PageSize? Should it exactly fit the visible height of the grid, or are you aiming for a visually balanced result depending on the theme and font? Hello! I know it is a complicated question. So It would be near perfect to know the header height ( with filter bar or not ) and rowheight depending on the theme to calculate pagesize. I think most of the cases is enough for grids without grouping and without multiline rows. Thanks in advance Quote
art Posted May 2, 2025 Author Posted May 2, 2025 On 4/29/2025 at 1:42 PM, Sherzod said: Hello, Just to clarify: even if we dynamically calculate the row height, what would you consider to be the correct way to determine the PageSize? Should it exactly fit the visible height of the grid, or are you aiming for a visually balanced result depending on the theme and font? Ok. I'll trying to find out something. Quote
art Posted May 5, 2025 Author Posted May 5, 2025 I tought something like this, but I'm not an UniGUI expert: function afterrender(grid) { var view = grid.getView(); var rowEl = view.getNode(0); var rowHeight = rowEl ? Ext.fly(rowEl).getHeight() : 26; var gridHeight = grid.getHeight(); var headerHeight = grid.headerCt ? grid.headerCt.getHeight() : 28; var pager = grid.getDockedItems('pagingtoolbar[dock="bottom"]')[0]; var pagerHeight = pager ? pager.getHeight() : 32; var extraPadding = 6; var usableHeight = gridHeight - headerHeight - pagerHeight - extraPadding; var pageSize = Math.floor(usableHeight / rowHeight) - 1; if (pageSize < 1) pageSize = 1; ajaxRequest(grid, 'SetPageSize', ['pageSize=' + pageSize]); } 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.