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
I am trying to Save/Restore a grids layout. I am using the command:
WebGrid1.SaveTablesStructureToXml(_file)
The structure is saved but when I try to restore the grid's layout the following problems occur:
1. The header styles that I have set is not restored
2. Template fields are not included.
I am restoring the layout in the InitializeLayout event.
I'm setting the header style in the RootTable definition:
<HeaderStyle BackColor="#2b5584" BorderColor="#2b5584" BorderStyle="Solid" BorderWidth="1px" Cursor="Hand" Font-Names="Verdana" Font-Size="8pt" ForeColor="White" Font-Bold="true" HorizontalAlign="Center" CustomRules="height:auto"> <BorderSettings> <Left Color="#2b5584" /> <Top Color="#2b5584" /> </BorderSettings> </HeaderStyle>
How can I make sure that the grid's defintion is used and how to restore templated fields?
thanks
SaveTablesStructureToXml allows you to save RootTable properties – including its Columns and ChildTables – along with all objects contained to an XML file. The table structure can be applied to WebGrid by using LoadTablesStructureFromXml method. The method will loads table file structure from an XML file and restore it to RootTable of WebGrid.
In order to save WebGrid’s layout, please try to use SaveLayoutToXml method. It saves WebGrid’s layout settings properties to XML file. Developers can save commonly used Layout and apply it to WebGrid by using the LoadLayoutFromXml method.
Regarding the template fields, I have reported this to WebGrid development team. The report is filed under work item #1080.
Please let us know whether this help or not.
Hi Yudi,
I am using saveTablesStructureToXml and restoring using LoadTablesStructureFromXml method, but on restoring the Header Style IS NOT applied, the style goes back to the default style and NOT the style that is described in the Header Style.
I suspect that the header style is conflicted with default style of WebGrid.
I enclosed a simple page of WebGrid where the HeaderStyle is loaded from XML file during OnInitializeLayout event. Please have the sample evaluated on your and let us know if you have different result.
Hi,
Your sample uses the Save/LoadLayoutFromXml function and this will restore the styles of the grid BUT it doesn't restore the columns that were displayed (when using Select Columns), or the sort order or grouping. For this you need to use SaveTablesStructuretoXML/LoadTablesStructureFromXML, which doesn't load the header styles. I've tried loading the structure than the layout (and reverse) but it does restore the grid to the condition the user had it set at when they saved the layout.
How can I get the table structure inlcuding styles, sorting, grouping and columns to the way the user has set the grid when they saved it?
I modify the sent sample to handle saving and loading table structure and table layout to XML file.
There are two XML file: WebGridTableLayout.xml and WebGridTableStructure.xml. WebGridTableLayout.xml is used to save the table layout of WebGrid while the WebGridTableStructure.xml is used to save the table structure of WebGrid.
Please find the attached sample and let us hear your feedback.
Your sample only has the WebGridTableStructure.xml and not the WebGridTableLayout.xml. I have saved both the layout and structure and when I retsore them, the header styles are NOT restored.
I re-send the sample files, SaveLoad TableStructure and Layout ToFrom XML File 2.zip. After extract the compressed file you should be able to find four files: SaveLoadWebGridTableStructureAndLayoutToFromXMLFile.aspx; SaveLoadWebGridTableStructureAndLayoutToFromXMLFile.aspx.cs; WebGridTableLayout.xml; and WebGridTableStructure.xml (SampleFileScreenshot.png).
The sample is intended to show WebGrid with no style at all when initially loaded in the browser (SampleFileInitiallyLoaded.png). After user press the “Load Structure and Layout” button, the column structure of WebGrid is changed based on the configuration loaded from WebGridTableStructure.xml file; and the HeaderStyle is applied – loaded from WebGridTableLayout.xml file.
Hope this help.
Ok, I see what the problem is...
In my grid defintion I am using the <headerStyle... under the <RootTable defintion and not in the layout settings, so when I save the layout the header style is not saved. If I move the <headerStyle to the Layout settings than the header style is saved and restored.
BUT
There is a difference in how the styles are applied based upon their location. When I use the <HeaderStyle under <RootTable, my header text is wrapped on those columns where the width of the column is less than the text. When used in the Layout settings, the header text is not wrapped.
Another problem is when the grid is first loaded and the layout and structure are applied in the WebGrid1_InitializeLayout event if I try to expand a preview row, it reloads the whole grid again via a postback and doesn't expand the preview row, unless I first click on a columns header to sort it, then the preview row will expand.
And the WebGrid1_InitializeRow event errors out if you try to modify a template field with error saying column doesn't exisit.
This is an important function for us.
Please forgive me for lack of understanding about the reported problem. Could you please show us the problem in a running simple sample or a screenshot?
Another problem is when the grid is first loaded and the layout and structure are applied in the WebGrid1_InitializeLayout event if I try to expand a preview row, it reloads the whole grid again via a postback and doesn't expand the preview row, unless I first click on a columns header to sort it, then the preview row will expand. And the WebGrid1_InitializeRow event errors out if you try to modify a template field with error saying column doesn't exisit. This is an important function for us.
I tried to reproduce the problem in my local test by modifying the SaveLoadWebGridTableStructureAndLayoutToFromXMLFile.aspx sample file (the sample which enclosed as attachment in my previous post on October 16, 2012 12:31 AM). Below is the detail modification made to the sample.
My efforts were not successful – everything worked smoothly and the preview row can be expanded without any postback or issues.
Please have the modified sample evaluated on your end and let me know if there is anything that I miss during my attempt to replicate the problem.
Thank you and have a nice day.
Here are screenshots that show the problem with the headers styles depending upon the location.
1. Grid1.png - this screenshot shows the grid header when the <headerStyle.. is located in the <RootTable definition as in...
<RootTable TableHeaderVisible="False" DataKeyField="CHALLENGE_ID" PreviewRowVisible="True"> <PreviewRowSettings DataMember="DESCRIPTION" DefaultExpanded="false" LoadOnDemand="True" Indentation="0px"> <Style ForeColor="Black" > </Style> </PreviewRowSettings> <HeaderStyle BackColor="#2b5584" BorderColor="#2b5584" BorderStyle="Solid" BorderWidth="1px" Cursor="Hand" Font-Names="Verdana" Font-Size="8pt" ForeColor="White" Font-Bold="true" HorizontalAlign="Center" CustomRules="height:auto"> <BorderSettings> <Left Color="#2b5584" /> <Top Color="#2b5584" /> </BorderSettings> </HeaderStyle>
2. Grid2.png - shows the header when the <HeaderStyle is located in the <LayoutSettings as in..
<LayoutSettings AllowFilter="Yes" AllowGrouping="Yes" AllowSorting="Yes" PagingMode="VirtualLoad" VirtualLoadMode="Custom" GroupByBoxVisible="False" AllowColumnFreezing="No" AllowColumnMove="Yes" AllowExport="No" AlwaysShowHelpButton="false" AllowSelectColumns="Yes" RowLostFocusAction="NeverUpdate" AutoFilterSuggestion="True" FilterBarVisible="false" HideColumnsWhenGrouped="No" InProgressUIBehavior="ChangeCursorToHourGlass" PagingSize="50" ShowFilterStatus="True" RestoreRowSelection="RootTableOnly" VirtualPageSize="50" PagingExportMode="ExportAllData" AllowMultipleSelection="No" GroupRowInfoFormatDefault="[caption] : [value] ([count])" ColumnFooters="Yes" HeaderClickAction="SortSingle" ShowColumnAction="true" RowHeaders="No" CellClickAction="CellSelect"> <HeaderStyle BackColor="#2b5584" BorderColor="#2b5584" BorderStyle="Solid" BorderWidth="1px" Cursor="Hand" Font-Names="Verdana" Font-Size="8pt" ForeColor="White" Font-Bold="true" HorizontalAlign="Center" CustomRules="height:auto"> <BorderSettings> <Left Color="#2b5584" /> <Top Color="#2b5584" /> </BorderSettings> </HeaderStyle> </LayoutSettings>
Look at the column headers for the difference. As for the other issues I will try to work up a sample.
Thank you for the sent screenshot. From the screenshot, I can see that Grid1.png shows multi line in the column header of WebGrid while the Grid2.png file shows a single line column header.
I have modified the sample sent on October 18, 2012 12:21 AM so that the LastName column header displayed in two lines. In this simple sample, I set the Caption of LastName column to “Last<br />Name in order to make it displayed as multiple line column header.
The HeaderStyle is placed inside the LayoutSettings object. If it is added inside the RootTable, the HeaderStyle is not saved into xml file when SaveLayoutToXml() method is invoked.
I was unable to reproduce the reported problem in my local end. Please have the attached sample tested on your end and let me know if you find anything that I miss during my attempt to reproduce the problematic behavior.
Yudi,
I have used the <br /> in the column headers but then when you use the Select Columns function to show/hide columns the names in the context menu shows the actual <br /> tag as part of the name.
I will look at your sample as soon as I can, but I have 2 major releases this month and can not spend much time with this function. At this point is to buggy to include!
Thank you for the feedback regarding the <br /> appearance on the pop-up menu when user use the Select Columns function to show/hide columns.
I’d like to confirm whether this problem persists or not when using the approach that currently used in your project. I assume that we may use different approach to achieve the multiline column header scenario. In my previous post, I use <br /> tag to create the multiple column header. If your technique doesn’t replicate the problem, please feel free to let me know. So that I can help you further by investigating why does the column header become a single line.
Look forward to hearing back from you.
Just wondering if anything has been done with work item #1080. I have a template field that is in a saved layout and it is not working properly.
In the WebGrid_InitializeRow event, I am looking for a template field to modify:
Dim cont As WebGridCellTemplateContainer = cells.GetNamedItem("Notes").GetTemplateContainer
If there is a Template field then I set the image within the template based on some data. All is fine if I haven't Saved a Layout. But if I save the grids layout and restore (InitializeLayout, PrepareDataBinding events ) it, the above line returns Nothing, so the code that sets the image never runs. I've looked at the XML that is generated when saving and the columnType is set as a template.
Any idea?
John
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