This is a migrated thread and some comments may be shown as answers.

[Solved] Datagrid becomes disabled when datapager is used.

2 Answers 131 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jacob Thomas
Top achievements
Rank 1
Jacob Thomas asked on 04 Nov 2009, 09:31 PM
When i try to use datapager with the datagrid, the grid is not selectable... I dont know wats wrong.

<UserControl x:Class="crmRequests.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"
xmlns:telerikNavigation ="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation"
xmlns:grid="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView"
xmlns:gridview="clr-namespace:Telerik.Windows.Controls.GridView;assembly=Telerik.Windows.Controls.GridView"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="600">
<Grid x:Name="LayoutRoot">
<telerikNavigation:RadTabControl FontSize="15" x:Name="tabControl" Margin="20" BorderThickness="1" Align="Justify" >
<telerikNavigation:RadTabItem Header="Home" Name="tabHome">

</telerikNavigation:RadTabItem>
<telerikNavigation:RadTabItem Header="Account Info">

</telerikNavigation:RadTabItem>
<telerikNavigation:RadTabItem Header="Knowledge Base">

</telerikNavigation:RadTabItem>
<telerikNavigation:RadTabItem Header="New Request">

</telerikNavigation:RadTabItem>
<telerikNavigation:RadTabItem Header="Open Requests" Name="tabOpenREquest">
<Grid>
<grid:RadGridView x:Name="gdOpenRequests" AutoGenerateColumns="False" ShowColumnFooters="True" IsReadOnly="True"></grid:RadGridView>
<data:DataPager x:Name="customerPager" Grid.Row="1" PageSize="100" Source="{Binding Path=ItemsSource,ElementName=gdOpenRequests}"></data:DataPager>
</Grid>
</telerikNavigation:RadTabItem>

<telerikNavigation:RadTabItem Header="Request History">
<Grid>
<grid:RadGridView x:Name="gdRequestHistory" ShowGroupFooters="True" AutoGenerateColumns="False" IsReadOnly="True"></grid:RadGridView>
</Grid>
</telerikNavigation:RadTabItem>
<telerikNavigation:RadTabItem Header="Audit My Workstation"/>

</telerikNavigation:RadTabControl>

</Grid>
</UserControl>

CodeBehind::
Imports System.Linq
Imports System.Xml
Imports System.Windows.Data
Imports System.Xml.Linq
Imports System.Collections
Imports System.Collections.Generic
Imports System.Collections.ObjectModel
Imports Telerik.Windows
Imports Telerik.Windows.Controls
Imports Telerik.Windows.Controls.GridView
Imports crmRequests.TestSrv

Partial Public Class MainPage
Inherits UserControl
Dim objTestSrv As TestSrv.TestServiceClient = Nothing
Private customers As ObservableCollection(Of clsCustomer)


Public Sub New()
InitializeComponent()
gdOpenRequests.[AddHandler](GridViewCell.MouseDoubleClickEvent, _
New EventHandler(Of RadRoutedEventArgs)(AddressOf Me.OnDoubleClickCellaGrigliaListino))
End Sub
Public Sub OnDoubleClickCellaGrigliaListino(ByVal sender As Object, ByVal e As RadRoutedEventArgs)
If Not IsNothing(e.Source) Then
Dim SelectedRow As GridViewRow = CType(e.Source, GridViewCell).ParentRow
MessageBox.Show("Name = " & SelectedRow.Cells(0).Content)
End If
End Sub
Private Sub MainPage_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles Me.Loaded
initGrid()
objTestSrv = New TestSrv.TestServiceClient()
objTestSrv.GetDataAsync()
AddHandler objTestSrv.GetDataCompleted, AddressOf objTestSrv_GetDataCompleted

End Sub
Private Sub initGrid()
gdOpenRequests.AutoGenerateColumns = False
gdOpenRequests.HorizontalAlignment = HorizontalAlignment.Center
gdOpenRequests.ColumnsWidthMode = ColumnsWidthMode.Fill
gdOpenRequests.ShowGroupPanel = False
gdOpenRequests.UseAlternateRowStyle = True
AddGridColumn("Name", "ContactName")
AddGridColumn("ID", "CustomerID")
AddGridColumn("EmailId", "ContactTitle")
AddGridColumn("Location", "CompanyName")
End Sub
Private Sub AddGridColumn(ByVal Name As String, ByVal UniquieName As String)
Dim Col As New GridViewDataColumn()
Col.Header = Name
Col.UniqueName = UniquieName
gdOpenRequests.Columns.Add(Col)
End Sub

Private Sub objTestSrv_GetDataCompleted(ByVal sender As Object, ByVal e As TestSrv.GetDataCompletedEventArgs)

If IsNothing(e.Error) Then
Dim obj() As crmRequests.TestSrv.stcCustomers
For Each aj As crmRequests.TestSrv.stcCustomers In e.Result
If IsNothing(obj) OrElse obj.Length = 0 Then
ReDim Preserve obj(0)
Else
ReDim Preserve obj(obj.Length)
End If
obj(obj.Length - 1) = aj
Next
Dim pgView As PagedCollectionView = New PagedCollectionView(e.Result)
' customerPager.Source = New PagedCollectionView(e.Result)
gdOpenRequests.ItemsSource = New PagedCollectionView(e.Result)
End If
End Sub
Protected Function GetCustomersFromDocument(ByVal document As XDocument) As ObservableCollection(Of clsCustomer)
Dim list As New ObservableCollection(Of clsCustomer)()

For Each element As XElement In document.Descendants("Customers")
Dim customer As New clsCustomer()
customer.CustomerID = element.Element("CustomerID").Value
customer.CompanyName = element.Element("CompanyName").Value
customer.Country = element.Element("Country").Value
customer.City = element.Element("City").Value
customer.ContactName = element.Element("ContactName").Value
customer.ContactTitle = element.Element("ContactTitle").Value
customer.Address = element.Element("Address").Value
customer.PostalCode = If(element.Element("PostalCode") IsNot Nothing, element.Element("PostalCode").Value, Nothing)
customer.Phone = element.Element("Phone").Value
customer.Fax = If(element.Element("Fax") IsNot Nothing, element.Element("Fax").Value, Nothing)
customer.Bool = CBool(element.Element("Bool"))

list.Add(customer)
Next

Return list
End Function
End Class

2 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 05 Nov 2009, 12:23 PM
Hi,

I'm not sure what is causing this issue at your end however you can check our demo where everything works fine.

Kind regards,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Jacob Thomas
Top achievements
Rank 1
answered on 05 Nov 2009, 04:04 PM
Hi Vlad,

I found the solution for this... Just have to keep the grid and the datapager inside a Stackflow with vertical orientation...

Thanks

Jacob
Tags
GridView
Asked by
Jacob Thomas
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Jacob Thomas
Top achievements
Rank 1
Share this question
or