Hi,
I am working on an application where I need to dynamically hide/unhide the columns. I have implemented that functionality. However, after hiding a few columns at runtime, if I try to reorder column by dragging dropping the columns, the RadGridView adds blank columns at the hidden columns' places. I have created a small sample demonstrating the issue.
Xaml File:
Code Behind:
CustomerOrder class:
Now, at runtime I can show/hide a column by opening the combobox and checking/unchecking the checkbox for any column. However, after hiding the column, if I try to reorder the column, the gridview adds a blank column. For example, after hiding the CustomerPONumber column, if I drag the ShipToId column and place it after ProductName column, the gridview add a blank column after PharmacyNotes column(where the hidden column was before hiding).
Please help. All inputs are appreciated.
Thanks,
Jaspreet Singh.
I am working on an application where I need to dynamically hide/unhide the columns. I have implemented that functionality. However, after hiding a few columns at runtime, if I try to reorder column by dragging dropping the columns, the RadGridView adds blank columns at the hidden columns' places. I have created a small sample demonstrating the issue.
Xaml File:
<
Window
x:Class
=
"AbstractionPOC.Window1"
Title
=
"Window1"
Height
=
"500"
Width
=
"900"
xmlns:telerik
=
"http://schemas.telerik.com/2008/xaml/presentation"
>
<
StackPanel
>
<
ComboBox
x:Name
=
"viewFields"
Grid.Column
=
"2"
ItemsSource
=
"{Binding Columns, ElementName=orderView}"
>
<
ComboBox.ItemTemplate
>
<
DataTemplate
>
<
CheckBox
Content
=
"{Binding Header}"
IsChecked
=
"{Binding IsVisible, Mode=TwoWay}"
/>
</
DataTemplate
>
</
ComboBox.ItemTemplate
>
</
ComboBox
>
<
telerik:RadGridView
Grid.Row
=
"1"
Grid.ColumnSpan
=
"4"
x:Name
=
"orderView"
SelectionMode
=
"Extended"
EditTriggers
=
"None"
AutoGenerateColumns
=
"True"
>
</
telerik:RadGridView
>
</
StackPanel
>
</
Window
>
Code Behind:
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
using
System.Windows;
using
System.Windows.Controls;
using
System.Windows.Data;
using
System.Windows.Documents;
using
System.Windows.Input;
using
System.Windows.Media;
using
System.Windows.Media.Imaging;
using
System.Windows.Shapes;
using
System.Collections.ObjectModel;
namespace
AbstractionPOC
{
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public
partial
class
Window1 : Window
{
public
ObservableCollection<CustomerOrder> CustomerOrders
{
get
;
set
;
}
public
Window1()
{
InitializeComponent();
CustomerOrders =
new
ObservableCollection<CustomerOrder>
{
new
CustomerOrder() {CustomerName=
"David Blaine"
, CustomerPONumber=
"PO123"
, PharmacyNotes=
"Some Pharmacy Notes"
, PrescriptionNumber=
"12345"
, ProductName=
"Cetrizine"
, ShipToId=387541},
new
CustomerOrder() {CustomerName=
"John Ruth"
, CustomerPONumber=
"PO654"
, PharmacyNotes=
"Some Other Notes"
, PrescriptionNumber=
"67890"
, ProductName=
"Brufen"
, ShipToId=12387},
new
CustomerOrder() {CustomerName=
"Jane Doe"
, CustomerPONumber=
"PO325"
, PharmacyNotes=
"More Pharmacy Notes"
, PrescriptionNumber=
"54321"
, ProductName=
"Crocin"
, ShipToId=65879},
new
CustomerOrder() {CustomerName=
"Robert Frost"
, CustomerPONumber=
"PO698"
, PharmacyNotes=
"Some More Notes"
, PrescriptionNumber=
"19875"
, ProductName=
"Paracetamole"
, ShipToId=234578},
new
CustomerOrder() {CustomerName=
"Tim Ferriss"
, CustomerPONumber=
"PO568"
, PharmacyNotes=
"Some Notes"
, PrescriptionNumber=
"15485"
, ProductName=
"Tetracycline"
, ShipToId=286541},
};
orderView.ItemsSource = CustomerOrders;
}
}
}
CustomerOrder class:
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
namespace
AbstractionPOC
{
public
class
CustomerOrder
{
public
string
CustomerName
{
get
;
set
;
}
public
string
ProductName
{
get
;
set
;
}
public
string
PharmacyNotes
{
get
;
set
;
}
public
string
CustomerPONumber
{
get
;
set
;
}
public
string
PrescriptionNumber
{
get
;
set
;
}
public
long
ShipToId
{
get
;
set
;
}
}
}
Now, at runtime I can show/hide a column by opening the combobox and checking/unchecking the checkbox for any column. However, after hiding the column, if I try to reorder the column, the gridview adds a blank column. For example, after hiding the CustomerPONumber column, if I drag the ShipToId column and place it after ProductName column, the gridview add a blank column after PharmacyNotes column(where the hidden column was before hiding).
Please help. All inputs are appreciated.
Thanks,
Jaspreet Singh.