如何从Silverlight Radgridview导出下拉列表的选定值 [英] How Do I Export Dropdown's Selected Value From Silverlight Radgridview
本文介绍了如何从Silverlight Radgridview导出下拉列表的选定值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用Silverlight telerik:RadGridView与MVVM绑定。在其中我使用了GridViewComboBoxColumn,它在导出到excel时没有导出选定的值。
代码如下。
I am using Silverlight telerik:RadGridView with MVVM binding. In it I have used GridViewComboBoxColumn which is not exporting selected value during export to excel.
Code is as below.
<telerik:RadGridView x:Name="gvFollowUp" IsReadOnly="False" GridLinesVisibility="Both" CanUserReorderColumns="True"
CanUserFreezeColumns="False" AutoGenerateColumns="False" AutoExpandGroups="True" IsFilteringAllowed="True" ItemsSource="{Binding FollowUpList}"
RowIndicatorVisibility="Collapsed" VerticalAlignment="Top" Margin="0,0,0,0" ShowColumnFooters="False" HorizontalAlignment="Stretch"
ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.HorizontalScrollBarVisibility="Auto" Height="Auto" Grid.Row="1"
NewRowPosition="Top" CellValidating="gvFollowUp_CellValidating" ValidatesOnDataErrors="InEditMode" CanUserInsertRows="True"
EditTriggers="Default">
<i:Interaction.Triggers>
<i:EventTrigger EventName="BeginningEdit">
<cmd:EventToCommand Command="{Binding BegningEdit}" PassEventArgsToCommand="True"/>
</i:EventTrigger>
<i:EventTrigger EventName="RowEditEnded">
<cmd:EventToCommand Command="{Binding RowEditEnd}" PassEventArgsToCommand="True"/>
</i:EventTrigger>
<i:EventTrigger EventName="AddingNewDataItem">
<cmd:EventToCommand Command="{Binding AddingNewDataItem}" PassEventArgsToCommand="True"/>
</i:EventTrigger>
</i:Interaction.Triggers>
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn Header="File #" x:Name="gvcFileNo" IsReadOnlyBinding="{Binding flg_completed, Converter={StaticResource BoolConverter},ConverterParameter=gvcFileNo}"
UniqueName="FileNo">
<telerik:GridViewDataColumn.CellTemplate>
<DataTemplate>
<HyperlinkButton NavigateUri="{Binding thisFollowUp.URUrl}" Content="{Binding LookUpReferenceCode.c2, Mode=OneTime}" ></HyperlinkButton>
</DataTemplate>
</telerik:GridViewDataColumn.CellTemplate>
<telerik:GridViewDataColumn.CellEditTemplate>
<DataTemplate>
<telerik:RadAutoCompleteBox x:Name="rcmbReference"
DisplayMemberPath="c2"
SelectionMode="Single"
SelectedItem="{Binding LookUpReferenceCode, Mode= TwoWay}"
ItemsSource="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=DataContext.ReferenceNo}"
BorderThickness="1"
HorizontalAlignment="Left"
AutoCompleteMode="SuggestAppend"/>
</DataTemplate>
</telerik:GridViewDataColumn.CellEditTemplate>
</telerik:GridViewDataColumn>
<telerik:GridViewComboBoxColumn x:Name="rcmbStatus"
Header="Status"
DataMemberBinding="{Binding LookUpSuspenseStatus, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
DisplayMemberPath="c2"
FilterMemberPath="LookUpSuspenseStatus.c2"
ItemsSourceBinding="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=DataContext.StatusLookUp}"
IsReadOnlyBinding="{Binding flg_completed, Converter={StaticResource BoolConverter},ConverterParameter=Status}"
IsVisible="False">
</telerik:GridViewComboBoxColumn>
</telerik:RadGridView.Columns>
</telerik:RadGridView>
public RelayCommand ExportCommand
{
get
{
return _ExportCommand
?? (_ExportCommand = new RelayCommand(
() =>
{
RadGridView grid = (Helper.Content.Content as Alis.Accounting.Controls.UCFollowUp).gvFollowUp;
if (grid != null)
{
grid.ElementExporting -= CurrentGrid_ElementExporting;
grid.ElementExporting += CurrentGrid_ElementExporting;
string extension = "xls";
var format = ExportFormat.Html;
var dialog = new SaveFileDialog();
dialog.DefaultExt = extension;
dialog.Filter = String.Format("{1} files (*.{0})|*.{0}|All files (*.*)|*.*", extension, "Excel");
dialog.FilterIndex = 1;
//dialog.DefaultFileName = "Follow Up-" + DateTime.Now.Date.ToShortDateString();
if (dialog.ShowDialog() == true)
{
using (var stream = dialog.OpenFile())
{
var exportOptions = new GridViewExportOptions();
exportOptions.Format = format;
exportOptions.ShowColumnFooters = true;
exportOptions.ShowColumnHeaders = true;
exportOptions.ShowGroupFooters = true;
grid.Export(stream, exportOptions);
}
}
}
}));
}
}
推荐答案
这篇关于如何从Silverlight Radgridview导出下拉列表的选定值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文