Hello!
I am having an issue that I can't explain and I hope you can.
I have hard coded a default layout for all users. When a user closes a form that a grid is on, the current grid layout is stored in the database and loaded the next time the users opens the form. I give the users the option (via a menu option) to reload the default layout. I do this by deleting record for the users layout, then call resetcolumns on each band in the grid (most grids only have one band) and then call the code to set the default layout.The code to reset the default layout has a call to the load from database routine but since no record exists is sets the default layout (column visibleposition, hidden and ExcludeFromColumnChooser properties). This works great (thanks to all who posted with this code).
We are changing the code to allow administrative users the ability to save a default layout for all users. I have added code to check to see if the user has a layout saved, if not, it tries to load the default saved by the administrator. This works great when the user does not have a saved layout and the form is loaded for the first time. The admins default layout loads without issue.
Here is my problem, when the user has a saved layout and they choose to reset the layout, I run through the code to reset to the saved default layout (delete the users layout, resetcolumns, load default from database). It does not appear that the load from the database happened at all. All columns are visible and in the order of the data.
Hello wlappin,
Please re-check which layout you are loading exactly and the order of resetting and loading the new layout. If the order is messed up, this could cause such issue. You should be sure about this. If however, you are sure that this is not the issue here I will ask you to try to attach if possible a small sample project reproducing this, I will be happy to take a look at it.
I am checking about the progress of this issue. Please let me know If you need any further assistance on this.
Hello,
Could you please try to attach if possible a small sample project reproducing the above mentioned issue, I will be happy to take a look at it.
Sorry it took so long to get back to this. I have verified the order and below are some code snippets. The LoadSavedGrid simply gets the grid layout from ListViewSaveTable and works correctly.
This is in the menu click event:
SQL = "Delete ListViewSave where UserId='" & gstrInspectorId & "' and Form='" & Name & "'" eData.ExecuteNonQuery(SQL) m_ResetLayout = True 'wel - v8.2.0 - 4/5/2012 - Changed to handle more than one band 'uGridMain.DisplayLayout().Bands(0).ResetColumns() For intI As Integer = 0 To uGridMain.DisplayLayout.Bands.Count - 1 uGridMain.DisplayLayout().Bands(intI).ResetColumns() uGridMain.Refresh() Next 'wel - v8.2.0 - 05/04/2012 - Added reset Column Swapping to the reset functionality uGridMain.DisplayLayout.Override.AllowColSwapping = AllowColSwapping.WithinBand InitDataGrid()
Here is the InitDataGrid Routine w/ other grid calls:
Friend Overrides Sub InitDataGrid(Optional ByVal WithFilters As Boolean = True) Try With uGridMain.DisplayLayout.Bands(0) If Not LoadSavedGrid(uGridMain, Name, WithFilters:=WithFilters) Then .Columns("InspectionDate").Header.SetVisiblePosition(0, False) .Columns("ActivityType").Header.SetVisiblePosition(1, False) .Columns("InspectionType").Header.SetVisiblePosition(2, False) .Columns("Description").Header.SetVisiblePosition(3, False) .Columns("InspectionNumber").Header.SetVisiblePosition(4, False) .Columns("NewViolations").Header.SetVisiblePosition(5, False) .Columns("OldViolations").Header.SetVisiblePosition(6, False) .Columns("CorrectedViolations").Header.SetVisiblePosition(7, False) .Columns("InspectionCause").Header.SetVisiblePosition(8, False) .Columns("Complete").Header.SetVisiblePosition(9, False) .Columns("AddressCode").Header.SetVisiblePosition(10, False) .Columns("AddressNumber").Header.SetVisiblePosition(11, False) .Columns("Direction").Header.SetVisiblePosition(12, False) .Columns("Address").Header.SetVisiblePosition(13, False) .Columns("Suffix").Header.SetVisiblePosition(14, False) .Columns("SubAddress").Header.SetVisiblePosition(15, False) .Columns("City").Header.SetVisiblePosition(16, False) .Columns("StateAbbr").Header.SetVisiblePosition(17, False) .Columns("Zip").Header.SetVisiblePosition(18, False) .Columns("PartyName").Header.SetVisiblePosition(19, False) .Columns("Phone").Header.SetVisiblePosition(20, False) .Columns("PhoneExt").Header.SetVisiblePosition(21, False) .Columns("Cell").Header.SetVisiblePosition(22, False) .Columns("CellExt").Header.SetVisiblePosition(23, False) .Columns("AltPartyName").Header.SetVisiblePosition(24, False) .Columns("Hrs").Header.SetVisiblePosition(25, False) HideColumns() End If .Columns("InspectionDate").Header.Caption = InspectionAlias & " Date" If TestSetting("Use24") AndAlso cSettings("Use24") Then .Columns("InspectionDate").Format = "MM/dd/yyyy HH:mm" Else .Columns("InspectionDate").Format = "MM/dd/yyyy hh:mm tt" End If .Columns("ActivityType").Header.Caption = InspectionAlias & " Category" .Columns("InspectionType").Header.Caption = InspectionAlias & " Type" .Columns("Description").Header.Caption = ItemAlias .Columns("InspectionNumber").Header.Caption = "Record #" .Columns("NewViolations").Header.Caption = "New " & InspectionDetailAlias .Columns("OldViolations").Header.Caption = "Old " & InspectionDetailAlias .Columns("CorrectedViolations").Header.Caption = "Corr " & InspectionDetailAlias .Columns("InspectionCause").Header.Caption = InspectionAlias & " Cause" .Columns("Complete").Header.Caption = "Complete" .Columns("AddressCode").Header.Caption = AddressAlias & " Code" .Columns("AddressNumber").Header.Caption = AddressAlias & " Number" .Columns("AddressNumber").SortComparer = AlphaCompare .Columns("Direction").Header.Caption = "Direction" .Columns("Address").Header.Caption = AddressAlias .Columns("Suffix").Header.Caption = "Suffix" .Columns("SubAddress").Header.Caption = "Sub " & AddressAlias .Columns("City").Header.Caption = "City" .Columns("StateAbbr").Header.Caption = "State" .Columns("Zip").Header.Caption = "Zip Code" .Columns("PartyName").Header.Caption = PartyAlias & " Name" .Columns("AltPartyName").Header.Caption = "Alternate " & PartyAlias & " Name" .Columns("Hrs").Header.Caption = "Hours" .Columns("EndDate").Header.Caption = "End Date" .Columns("StartDate").Header.Caption = "Start Date" .Columns("PrimaryParty").Header.Caption = "Primary " & PartyAlias 'pdb - v8.2.0 - 05/04/2012 - Added for more column aliasing .Columns("FullAddress").Header.Caption = "Full " & AddressAlias .Columns("ViolationCounts").Header.Caption = InspectionDetailAlias & " Counts" .Columns("PrimaryParty").Header.Caption = "Primary " & PartyAlias 'wel - v8.2.0 - 05/07/2012 - Added Try Block to correct an error. Try .Columns("MailingAddress").Header.Caption = "Mailing " & AddressAlias .Columns("MailingSubAddress").Header.Caption = "Mailing Sub" & AddressAlias .Columns("MailAddressCSZ").Header.Caption = "Mail " & AddressAlias & " CSZ" .Columns("AltMailingAddress").Header.Caption = "Alt Mailing " & AddressAlias .Columns("AltMailingSubAddress").Header.Caption = "Alt Mailing Sub " & AddressAlias .Columns("AltMailAddressCSZ").Header.Caption = "Alt Mail " & AddressAlias & " CSZ" Catch End Try 'pdb - v8.2.0 - 05/04/2012 - End Added for more column aliasing 'pdb - v8.2.0 - 05/08/2012 - Added .Columns("ItemInspectionStatus").Header.Caption = ItemAlias & " " & InspectionAlias & " Status" 'HideColumns() End With Catch ex As Exception HandleError(ex, Name, "InitDataGrid") End Try End Sub Private Sub HideColumns() Try With uGridMain.DisplayLayout.Bands(0) .Columns("ParentInspectionId").Hidden = True .Columns("ParentInspectionId").ExcludeFromColumnChooser = Win.UltraWinGrid.ExcludeFromColumnChooser.True .Columns("ViolationCounts").Hidden = True .Columns("FullAddress").Hidden = True .Columns("StateId").Hidden = True .Columns("StateId").ExcludeFromColumnChooser = Win.UltraWinGrid.ExcludeFromColumnChooser.True .Columns("ZipId").Hidden = True .Columns("ZipId").ExcludeFromColumnChooser = Win.UltraWinGrid.ExcludeFromColumnChooser.True .Columns("ActivityTypeId").Hidden = True .Columns("ActivityTypeId").ExcludeFromColumnChooser = Win.UltraWinGrid.ExcludeFromColumnChooser.True .Columns("InspectionTypeId").Hidden = True .Columns("InspectionTypeId").ExcludeFromColumnChooser = Win.UltraWinGrid.ExcludeFromColumnChooser.True .Columns("InspectionId").Hidden = True .Columns("InspectionId").ExcludeFromColumnChooser = Win.UltraWinGrid.ExcludeFromColumnChooser.True .Columns("InspectionCauseId").Hidden = True .Columns("InspectionCauseId").ExcludeFromColumnChooser = Win.UltraWinGrid.ExcludeFromColumnChooser.True .Columns("AddressId").Hidden = True .Columns("AddressId").ExcludeFromColumnChooser = Win.UltraWinGrid.ExcludeFromColumnChooser.True .Columns("InspectorId").Hidden = True .Columns("InspectorId").ExcludeFromColumnChooser = Win.UltraWinGrid.ExcludeFromColumnChooser.True .Columns("InspectedPartyId").Hidden = True .Columns("InspectedPartyId").ExcludeFromColumnChooser = Win.UltraWinGrid.ExcludeFromColumnChooser.True .Columns("AlternatePartyId").Hidden = True .Columns("AlternatePartyId").ExcludeFromColumnChooser = Win.UltraWinGrid.ExcludeFromColumnChooser.True .Columns("RegionId").Hidden = True .Columns("RegionId").ExcludeFromColumnChooser = Win.UltraWinGrid.ExcludeFromColumnChooser.True .Columns("CountyId").Hidden = True .Columns("CountyId").ExcludeFromColumnChooser = Win.UltraWinGrid.ExcludeFromColumnChooser.True .Columns("OccupancyTypeId").Hidden = True .Columns("OccupancyTypeId").ExcludeFromColumnChooser = Win.UltraWinGrid.ExcludeFromColumnChooser.True .Columns("PropertyUseTypeId").Hidden = True .Columns("PropertyUseTypeId").ExcludeFromColumnChooser = Win.UltraWinGrid.ExcludeFromColumnChooser.True .Columns("PrimaryParty").Hidden = True .Columns("Inactive").Hidden = True .Columns("InspectorName").Hidden = True .Columns("ACAgencyId").Hidden = True .Columns("ACAgencyId").ExcludeFromColumnChooser = Win.UltraWinGrid.ExcludeFromColumnChooser.True .Columns("InspAgencyId").Hidden = True .Columns("InspAgencyId").ExcludeFromColumnChooser = Win.UltraWinGrid.ExcludeFromColumnChooser.True .Columns("GroupId").Hidden = True .Columns("GroupId").ExcludeFromColumnChooser = Win.UltraWinGrid.ExcludeFromColumnChooser.True .Columns("RoutingSlipId").Hidden = True .Columns("RoutingSlipId").ExcludeFromColumnChooser = Win.UltraWinGrid.ExcludeFromColumnChooser.True .Columns("EndDate").Hidden = True .Columns("ApprovalStep").Hidden = True .Columns("ItemId").Hidden = True .Columns("ItemId").ExcludeFromColumnChooser = Win.UltraWinGrid.ExcludeFromColumnChooser.True .Columns("ActInactive").Hidden = True .Columns("TypeInactive").Hidden = True .Columns("PartyAlias").Hidden = True .Columns("PartyAlias").ExcludeFromColumnChooser = Win.UltraWinGrid.ExcludeFromColumnChooser.True .Columns("AddressAlias").Hidden = True .Columns("AddressAlias").ExcludeFromColumnChooser = Win.UltraWinGrid.ExcludeFromColumnChooser.True '.Columns("ttxInspectorName").Hidden = True '.Columns("ttxInspectorPhone").Hidden = True '.Columns("ttxFromDate").Hidden = True '.Columns("ttxToDate").Hidden = True '.Columns("ttxStatus").Hidden = True '.Columns("ttxPartyName").Hidden = True '.Columns("ttxActivityType").Hidden = True '.Columns("ttxInspectionType").Hidden = True '.Columns("ttxCity").Hidden = True '.Columns("ttxZip").Hidden = True '.Columns("ttxRegion").Hidden = True 'If cboType.Text = AddressAlias & " Range" Then ' .Columns("ttxAddressNumber").Hidden = True ' .Columns("ttxStreetName").Hidden = True ' .Columns("ttxSuffix").Hidden = True 'Else ' .Columns("ttxAddressNumFrom").Hidden = True ' .Columns("ttxAddressNumTo").Hidden = True ' .Columns("ttxStreet").Hidden = True ''End If '.Columns("ttxDirection").Hidden = True '.Columns("ttxSubAddress").Hidden = True '.Columns("ttxCounty").Hidden = True '.Columns("ttxOccupancy").Hidden = True '.Columns("ttxPropertyUse").Hidden = True '.Columns("ShowDetails").Hidden = True Try '.Columns("ttxPartyName1").Hidden = True .Columns("MailingAddress").Hidden = True .Columns("MailingSubAddress").Hidden = True .Columns("MailAddressCSZ").Hidden = True .Columns("AltMailingAddress").Hidden = True .Columns("AltMailingSubAddress").Hidden = True .Columns("AltMailAddressCSZ").Hidden = True '.Columns("ttxAddressNumFrom").Hidden = True '.Columns("ttxAddressNumTo").Hidden = True Catch End Try .Columns("ACGroupId").Hidden = True .Columns("ACGroupId").ExcludeFromColumnChooser = Win.UltraWinGrid.ExcludeFromColumnChooser.True .Columns("SecondaryInspectorId").Hidden = True .Columns("SecondaryInspectorId").ExcludeFromColumnChooser = Win.UltraWinGrid.ExcludeFromColumnChooser.True .Columns("SecondaryInspectorName").Hidden = True .Columns("Barcode").Hidden = True .Columns("SecAddressId").Hidden = True .Columns("SecAddressId").ExcludeFromColumnChooser = Win.UltraWinGrid.ExcludeFromColumnChooser.True .Columns("ItemInspectionStatusId").Hidden = True .Columns("ItemInspectionStatusId").ExcludeFromColumnChooser = Win.UltraWinGrid.ExcludeFromColumnChooser.True .Columns("Phone").Hidden = True .Columns("PhoneExt").Hidden = True .Columns("Cell").Hidden = True .Columns("CellExt").Hidden = True .Columns("StartDate").Hidden = True End With Catch ex As Exception HandleError(ex, Name, "HideColumns") End Try End Sub