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 having a problem with my webgrid columns resizing after postback. I've attached a before an after image to illustrate the problem. During the loading of the page, I add the rows in the code behind. I then post back to the server for processing, and rebind the grid. Code is below:
<ISWebGrid:WebGrid ID="wbCompareResults" runat="server" Height="75%" Width="100%" UseDefaultStyle="true" EnableWebResources="Always" CustomSchemaRetrieval="UseWebGrid"> <RootTable GridLineStyle="NotSet"> <Columns> <ISWebGrid:WebGridColumn ColumnType="Custom" Width="35px" AllowSizing="No" /> <ISWebGrid:WebGridColumn ColumnType="Text" Width="35px" Name="Tran" AllowSizing="No" /> <ISWebGrid:WebGridColumn ColumnType="Text" Width="50px" Name="Num" AllowSizing="No" /> <ISWebGrid:WebGridColumn ColumnType="Text" Width="10px" AllowSizing="No" /> <ISWebGrid:WebGridColumn ColumnType="Text" Width="50px" Name="LT" AllowSizing="No" /> <ISWebGrid:WebGridColumn ColumnType="Text" Width="10px" AllowSizing="No" /> <ISWebGrid:WebGridColumn ColumnType="Text" Width="50px" Name="BT" AllowSizing="No" /> <ISWebGrid:WebGridColumn ColumnType="Text" Width="10px" AllowSizing="No" /> <ISWebGrid:WebGridColumn ColumnType="Text" Width="50px" Name="BC" AllowSizing="No" /> <ISWebGrid:WebGridColumn ColumnType="Text" Width="10px" AllowSizing="No" /> <%--<ISWebGrid:WebGridColumn ColumnType="Custom" IsAutoWidth="true" AllowSizing="Yes" Name="Description" Caption="Description" /> <ISWebGrid:WebGridColumn ColumnType="Custom" IsAutoWidth="true" AllowSizing="Yes" Name="Field" Caption="Field" /> <ISWebGrid:WebGridColumn ColumnType="Custom" IsAutoWidth="true" AllowSizing="Yes" Name="Value" Caption="Value" />--%> <ISWebGrid:WebGridColumn ColumnType="Custom" Width="725px" AllowSizing="Yes" Name="Description" Caption="Description" /> <ISWebGrid:WebGridColumn ColumnType="Custom" Width="110px" AllowSizing="Yes" Name="Field" Caption="Field" /> <ISWebGrid:WebGridColumn ColumnType="Custom" Width="110px" AllowSizing="Yes" Name="Value" Caption="Value" /> </Columns> </RootTable> <LayoutSettings AllowEdit="No" AlternatingColors="false" GridLines="Horizontal" PagingMode="None" AutoHeight="true" AutoFitColumns="false" StatusBarVisible="false"> <AlternatingRowStyle CustomRules="text-overflow: ellipsis; overflow: hidden;" Wrap="false" BackColor="White" Font-Size="8pt" Font-Names="Arial Monospaced"></AlternatingRowStyle> <RowStyle CustomRules="text-overflow: ellipsis; overflow: hidden;" Wrap="false" BackColor="White" Font-Size="8pt" Font-Names="Arial Monospaced"></RowStyle> </LayoutSettings> </ISWebGrid:WebGrid>
Code behind - this is what is execute after the post back:
''' <summary> ''' binds this list to the grid ''' </summary> ''' <param name="results"></param> ''' <remarks></remarks> Private Sub BindGrid(ByVal results As List(Of String())) ' Note (XXX): we can't bind the grid by simply setting the datasource property since this is a list of string arrays ' we have to iterate through the list and add each row manually If results IsNot Nothing Then For i As Integer = 0 To results.Count - 1 Dim data As String() = results(i) Me.wbCompareResults.RootTable.Rows().Add(New ISNet.WebUI.WebGrid.WebGridRow(data)) Next End If End Sub
Everything seems to bind just find, but my first row is never sized as it was.
Thanks for your help!
<Columns> <ISWebGrid:WebGridColumn ColumnType="Custom" Width="35px" AllowSizing="No"/> <ISWebGrid:WebGridColumn ColumnType="Text" Width="35px" Name="Tran" AllowSizing="No" /> <ISWebGrid:WebGridColumn ColumnType="Text" Width="50px" Name="Num" AllowSizing="No" /> ... </Columns> ... Modify to: ... <Columns> <ISWebGrid:WebGridColumn ColumnType="Custom" Width="35px" AllowSizing="No" Name="CheckBoxColumn" /> <ISWebGrid:WebGridColumn ColumnType="Text" Width="35px" Name="Tran" AllowSizing="No" /> <ISWebGrid:WebGridColumn ColumnType="Text" Width="50px" Name="Num" AllowSizing="No" /> ... </Columns> ...
I also attached my sample.
Hope this helps. Thank you.
Regards,
Hans.
function WebGrid1_OnInitialize(controlId) { var WebGrid1 = ISGetObject(controlId); wgDoResize(true, true); return true; }
Then please ensure that you are using our latest hotfix version for WebGrid and the framework.
If the issue still occur, could you tell me the step by step how to reproduce this issue?
Or if you don’t mind, could you please send me a simple project that replicate this issue?
So that I can investigate this issue further.
Thanks Hans, but this doesn't solve the problem.
I downloaded the latest hotfixes and updates but that hasn't worked either.
To recreate:
1. Create a grid with the same columsn I've created above.
2. On initial page load, you can create a List(of String()) of some values i.e.
dim rowData1 as String() = {"", "1", "1", "(", "1", ",", "1", ",", "1", ")", "1", "", "") dim rowData2 as String() = {"", "2", "2", "(", "2", ",", "2", ",", "2", ")", "2", "", "") dim myList as new List(of String()) myList.add(rowData1); myList.add(rowData2);dim newRow as New WebGridRow(myList);myGrid.RootTable.Rows().add(newRow);
Add as many of these as you want. Save this list in the session somewhere too.
3. Add a button on the screen that will create a post back. For that buttons handler, retreive the data from session, iterate through the list and add the rows again i.e.
Below is the RowInitialize handler for the grid. I am inserting a checkbox for the first column:
Private Sub wbCompareResults_InitializeRow(sender As Object, e As ISNet.WebUI.WebGrid.RowEventArgs) Handles wbCompareResults.InitializeRow If e.Row.Type = ISNet.WebUI.WebGrid.RowType.Record Then ' add the checbox control ' I had some other code here for the checkbox, but this should be sufficient. e.Row.Cells(0).Text = "<input type=""checkbox""/>" End If End Sub
I also added the client side OnInitialize function you provided.
Looking forward to your response.
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