May 09, 2013, 11:37 PM
[CLOSED] Column Locking not working when using GridPanel.Reconfigure
I am trying to lock few columns on my grid, but setting Locked = True seems to have no effect.
Below is a sample to reproduce the problem -
When you click 'Show Offices', it loads up the Office data and in the 'GetEmployeesColumns' method, I've set the first 2 columns to be locked.
Below is a sample to reproduce the problem -
When you click 'Show Offices', it loads up the Office data and in the 'GetEmployeesColumns' method, I've set the first 2 columns to be locked.
<%@ Page Language="vb" %>
<%@ Register TagPrefix="ext" Namespace="Ext.Net" Assembly="Ext.Net" %>
<%@ Import Namespace="Ext.Net" %>
<script runat="server">
Private Shared LAST_NAMES As String() = New String() {"Jones", "Smith", "Lee", "Wilson", "Black", "Williams", _
"Lewis", "Johnson", "Foot", "Little", "Vee", "Train", _
"Hot", "Mutt"}
Private Shared FIRST_NAMES As String() = New String() {"Fred", "Julie", "Bill", "Ted", "Jack", "John", _
"Mark", "Mike", "Chris", "Bob", "Travis", "Kelly", _
"Sara"}
Private Shared CITIES As String() = New String() {"New York", "Los Angeles", "Chicago", "Houston", "Philadelphia", "Phoenix", _
"San Antonio", "San Diego", "Dallas", "San Jose"}
Private Shared DEPARTMENTS As String() = New String() {"Development", "QA", "Marketing", "Accounting", "Sales"}
Private Shared RANDOM As New Random()
Public Class Office
Public Property City() As String
Get
Return m_City
End Get
Set(value As String)
m_City = value
End Set
End Property
Private m_City As String
Public Property Manager() As String
Get
Return m_Manager
End Get
Set(value As String)
m_Manager = value
End Set
End Property
Private m_Manager As String
Public Property TotalEmployees() As Integer
Get
Return m_TotalEmployees
End Get
Set(value As Integer)
m_TotalEmployees = value
End Set
End Property
Private m_TotalEmployees As Integer
End Class
Public Class Employee
Public Property FirstName() As String
Get
Return m_FirstName
End Get
Set(value As String)
m_FirstName = value
End Set
End Property
Private m_FirstName As String
Public Property LastName() As String
Get
Return m_LastName
End Get
Set(value As String)
m_LastName = value
End Set
End Property
Private m_LastName As String
Public Property No() As Integer
Get
Return m_No
End Get
Set(value As Integer)
m_No = value
End Set
End Property
Private m_No As Integer
Public Property Department() As String
Get
Return m_Department
End Get
Set(value As String)
m_Department = value
End Set
End Property
Private m_Department As String
End Class
Private Function GetUnigueCity(usedCities As List(Of String)) As String
Dim city As String = CITIES(RANDOM.[Next](CITIES.Length))
If usedCities.Contains(city) Then
Return Me.GetUnigueCity(usedCities)
Else
usedCities.Add(city)
Return city
End If
End Function
Private Function GetUnigueName(usedNames As List(Of String)) As String()
Dim firstName As String = FIRST_NAMES(RANDOM.[Next](FIRST_NAMES.Length))
Dim lastName As String = LAST_NAMES(RANDOM.[Next](LAST_NAMES.Length))
Dim name As String() = New String() {firstName, lastName}
Dim key As String = firstName & lastName
If usedNames.Contains(key) Then
Return Me.GetUnigueName(usedNames)
Else
usedNames.Add(key)
Return name
End If
End Function
Private Function GetOfficesData() As Object()
Dim data As Office() = New Office(6) {}
Dim usedNames As New List(Of String)()
Dim usedCities As New List(Of String)()
For i As Integer = 0 To 6
Dim name As String() = Me.GetUnigueName(usedNames)
data(i) = New Office() With { _
.City = Me.GetUnigueCity(usedCities), _
.Manager = name(0) & " " & name(1), _
.TotalEmployees = RANDOM.[Next](10, 25) _
}
Next
Return data
End Function
Private Function GetEmployeesData() As Object()
Dim data As Employee() = New Employee(19) {}
Dim usedNames As New List(Of String)()
For i As Integer = 0 To 19
Dim name As String() = Me.GetUnigueName(usedNames)
data(i) = New Employee() With { _
.FirstName = name(0), _
.LastName = name(1), _
.No = Integer.Parse(RANDOM.[Next](100, 200).ToString() + RANDOM.[Next](100, 200).ToString()), _
.Department = DEPARTMENTS(RANDOM.[Next](DEPARTMENTS.Length)) _
}
Next
Return data
End Function
Private Function GetOfficeStore() As AbstractStore
Dim store As New Store()
store.Data = Me.GetOfficesData()
store.Fields.Add("City", "TotalEmployees", "Manager")
Return store
End Function
Private Function GetEmployeesStore() As AbstractStore
Dim store As New Store()
store.Data = Me.GetEmployeesData()
store.Fields.Add("FirstName", "LastName", "No", "Department")
Return store
End Function
Private Function GetOfficesColumns() As ColumnBase()
Return New ColumnBase() {New Column() With { _
.Text = "City", _
.DataIndex = "City", _
.Width = 140, _
.Locked = True
}, New Column() With { _
.Text = "Total Employees", _
.DataIndex = "TotalEmployees", _
.Width = 140, _
.Locked = True
}, New Column() With { _
.Text = "Manager", _
.DataIndex = "Manager", _
.Width = 120 _
}}
End Function
Private Function GetEmployeesColumns() As ColumnBase()
Return New ColumnBase() {New Column() With { _
.Text = "First Name", _
.DataIndex = "FirstName", _
.Flex = 1 _
}, New Column() With { _
.Text = "Last Name", _
.DataIndex = "LastName", _
.Flex = 1 _
}, New Column() With { _
.Text = "Employee No.", _
.DataIndex = "No", _
.Width = 120 _
}, New Column() With { _
.Text = "Department", _
.DataIndex = "Department", _
.Flex = 1 _
}}
End Function
Protected Sub ShowOfficesButton_Click(sender As Object, e As DirectEventArgs)
Me.GridPanel1.Title = "Offices"
Me.GridPanel1.Reconfigure(Me.GetOfficeStore(), Me.GetOfficesColumns())
Me.ShowOfficesButton.Disabled = True
Me.ShowEmployeesButton.Disabled = False
End Sub
Protected Sub ShowEmployeesButton_Click(sender As Object, e As DirectEventArgs)
Me.GridPanel1.Title = "Employees"
Me.GridPanel1.Reconfigure(Me.GetEmployeesStore(), Me.GetEmployeesColumns())
Me.ShowEmployeesButton.Disabled = True
Me.ShowOfficesButton.Disabled = False
End Sub
</script>
<!DOCTYPE html>
<html>
<head id="Head1" runat="server">
<title>Reconfigure GridPanel - Ext.NET Examples</title>
<link href="/resources/css/examples.css" rel="stylesheet" />
</head>
<body>
<form id="Form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server" />
<ext:Viewport ID="Viewport1" runat="server" Margins="0 0 10 0">
<LayoutConfig>
<ext:VBoxLayoutConfig Align="Center" Pack="Center" />
</LayoutConfig>
<Items>
<ext:Container ID="Container1" runat="server" Width="500" Height="330">
<LayoutConfig>
<ext:VBoxLayoutConfig Align="Stretch" />
</LayoutConfig>
<Items>
<ext:Container ID="Container2" runat="server" Layout="HBoxLayout">
<Items>
<ext:Button ID="ShowOfficesButton" runat="server" Text="Show Offices" OnDirectClick="ShowOfficesButton_Click" />
<ext:Button ID="ShowEmployeesButton" runat="server" Text="Show Employees" OnDirectClick="ShowEmployeesButton_Click"
Margins="0 0 0 10" />
</Items>
</ext:Container>
<ext:GridPanel ID="GridPanel1" runat="server" Flex="1" Title="Selected Department goes here ... ">
</ext:GridPanel>
</Items>
</ext:Container>
</Items>
</ext:Viewport>
</form>
</body>
</html>
Last edited by Baidaly; May 10, 2013 at 8:18 PM.
Reason: [CLOSED]