iSeller Commerce
iSeller POS Retail
iSeller POS F&B
iSeller POS Express
Crosslight
WebUI
ClientUI
What's New
Download Trial
Web Solution
Mobile Solution
Enterprise Solution
Custom Development
Blog
Community
Latest Development Blogs
ForumPostTopic
Browse By Tag
Hi,
I'm trying to resize the grid to fit all the rows without scrolling... this seems to work for the initial load as I'm doing this onPreRender (all I'm doing is determinen the gridHeight based on webGrid.RootTable.Rows.Count + the extras available (filter bar, group by box, etc).
My problem is that during a FlyPostBack I can't resize the grid (as some operations add records and just call Grid.ClientActions.Refresh()). I'm using the GridLoad event (as I should have available the rowcount in there).
webGrid.Load += OnLoadGrid; /// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void OnLoadGrid(object sender, EventArgs e) { int baseHeight = 81; int perRowHeight = 21; int gridHeight = baseHeight + webGrid.RootTable.Rows.Count * perRowHeight; webGrid.Height = Unit.Pixel(gridHeight); webGrid.RequiresUIRefresh = true; }
Is there a way to programmatically resize the grid on every PostBack/FlyPostback?
If you don't want to show scrollbar at WebGrid right position, you can use grid.HidePadColumn = false; (javascript).
Also, I don't quite understand why do you need refresh the grid after added a new row in WebGrid. Refresh() would not have any effect to the layout. RefreshAll() should be the one for WebGrid structure.
As far I know, the scrollbar would be appeared if the records in the WebGrid content are not fit with WebGrid height. So, perhaps you would need to SetHeight WebGrid (as Yudhiy suggestion).
It depends on the container and WebGrid height/structure itself.
WebGrid would automatically resize for the best fit/ layout size.
Normally, WebGrid called wgDoResize() to resize function itself.
e.g if you resize the browser, WebGrid should be resized itself.
If WebGrid does not resize itself after FlyPostBack request, you can try to call this method OnAfterResponse client side event.
It would be more helpful if you can provide a simple runable sample. By following your WebGrid settings and structure, we can discuss the best approach for your scenario.
Regards, Handy
Please try to resize grid height in OnLoad server-side event. Due to WebGrid’s documentation that explains about event sequence of WebGrid’s server-side events, this event will be executed both during ‘not’ on the FlyPostBack and on the FlyPostBack.
In order to determine whether current event is FlyPostBack or not, IsPostBack flag can be utilized. IsPostBack’s value indicates whether the page is being loaded in response to client postback (FlyPostBack) or if it is being loaded and accessed for the first time.
If IsPostBack is true (on the FlyPostBack), use InvokeScript method to call client-side script (javascript function) that will resize WebGrid’s height. In client-side, simply call ‘SetHeight(height parameter in pixel unit)’ method to resize WebGrid’s height.
If IsPostBack is false (not on the FlyPostBack), then set grid height programmatically in code behind. Below is the snippet code that I use on my test page to test your scenario.
protected void WebGrid1_Load(object sender, EventArgs e) { if (IsPostBack) WebGrid1.ClientAction.InvokeScript("ResizeHeight();"); else WebGrid1.Height = Unit.Pixel(600); }
<script type="text/javascript"> <!-- function ResizeHeight() { var WebGrid1 = ISGetObject("WebGrid1"); WebGrid1.SetHeight(400); return true; } --> </script>
Hope this helps.
Hi Yudi,
Thanks for you reply, it's still not what I need (and I see autoheight still has issues with the XHTML Doctype so that's not an option).
I'm adding entries to my DataSource and refreshing the grid via a javascript Refresh()... problem is, your approach resizes the container, it's not really refitting the content in the grid to ocupy the new given height. Please see the attachments to see whatI'm talking about.... in ResizeGrid2 you can see the grid grows past the original position of the status bar but it displays as an empty canvas.
I went with another solution, instead of having a javascript function do the refresh, have it fire a customrequest.... then catch that onInitializePostback and there resize-refresh (with this effectively using two FlyPostBacks to refresh), but the same thing happens:
protected void ResizeAndRefresh(object sender, ISNet.WebUI.WebGrid.PostbackEventArgs e) { if (e.Action == ISNet.WebUI.WebGrid.PostBackAction.Custom) { webGrid.ClientAction.InvokeScript( string.Format("Resize({0});", GetNewGridHeight()) ); webGrid.ClientAction.Refresh(); } }
Is there any way to resize (and re-fit) the grid?
Edit: Ok, so much for the attach file... It's not working.
What ClientSide function I can use to change WebGrid Width ?
Best Regards,
Michal
Please try to set the grid’s width in OnAfterResponse client-side event.Hope this helps.
or
Choose this if you're already a member of Intersoft Community Forum. You can link your OpenID account to your existing Intersoft Social ID.
Choose this if you don't have an Intersoft account yet. Your authenticated OpenID will be automatically linked to your new Intersoft account.
Enter your Wordpress Blogname