Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Silverlight > GridView > bug when exporting radgridview with gridviewcomboboxcolumn

Not answered bug when exporting radgridview with gridviewcomboboxcolumn

Feed from this thread
  • Val avatar

    Posted on Feb 6, 2012 (permalink)

    Hi,

    Here is my problem, I have a radgridview with two columns (x and y for example).
    For x :

     

    <telerikGridView:GridViewDataColumn Header="aHeader" DataMemberBinding="{Binding NAME}" Width="Auto" IsReadOnly="True" />
    and for y :
    <telerikGridView:GridViewComboBoxColumn UniqueName="Uniquename" Header="anotherHeader" Width="*" 
                                                            ItemsSourceBinding="{Binding ListConfigurationsOrderByIndexWithNullConf}"                                                                       
                                                            DisplayMemberPath="NAME"
                                                            DataMemberBinding="{Binding SelectedConfiguration}"
                                                            >
                        <telerikGridView:GridViewComboBoxColumn.CellTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding SelectedConfiguration.NAME}" />
                            </DataTemplate>
                        </telerikGridView:GridViewComboBoxColumn.CellTemplate>
                    </telerikGridView:GridViewComboBoxColumn>

    everything works well, but when I'm exporting the radgridview into xls, for y column I only have the values of what is displaying on the screen. In other words, my radgridview has a scrollbar because there are a lot of elements, but only the rows i can see on the screen are taken into account for exporting whereas I want all to be exported.
    Sorry for my English and thanks in advance,

    Val

    Reply

  • Val avatar

    Posted on Feb 7, 2012 (permalink)

    more details :

    I have this function call when exporting :
    private void radgridview_Exporting(object sender, GridViewElementExportingEventArgs e)
            {
                if (e.Context != null)
                {
                    if (e.Element == ExportElement.Row)
                    {
                        _confToExport = (A_STRUCTURE)((GridViewRow)e.Context).Item;
                    }
                    else if (e.Element == ExportElement.Cell && e.Context is GridViewComboBoxColumn)
                    {
                        if (_confToExport.SelectedConfiguration != null)
                        {
                              e.Value = _confToExport.SelectedConfiguration.NAME;
                        }
                    }
                }
            }

    The problem occurs for  if(e.Element == ExportElement.Row), only visible rows on the screen are taken into account (whereas for example, all ExportElement.Cell are).
    I tried different approaches to solve my problem but I cant find any solutions...
    Val

    Reply

  • Pavel Pavlov Pavel Pavlov admin's avatar

    Posted on Feb 7, 2012 (permalink)

    Hello Valentin,

     
    Indeed RadGridView would traverse the visual tree in order to get the exported result as close to what you see as possible.  By default it has the row virtualization turned on . This provides a great scrolling performance boost as only the elements visible in the viewport are considering for rendering , databinding etc.

    To have all the elements realized ( not only the ones in the viewport) you will need to turn off the row virtualization e.g. this.RadGridView1.EnableRowVirtualization = false;
    An alternative would be to place RadGridView into a panel that would measure it with infinity e.g. a stack panel ( vertical).

    All the best,
    Pavel Pavlov
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>

    Reply

  • Val avatar

    Posted on Feb 8, 2012 (permalink)

    I also find a solution to solve my problem by changing my code like that :
    private void radgridview_Exporting(object sender, GridViewElementExportingEventArgs e)
            {
                if (e.Element == ExportElement.Row)
                {
                    _confToExport = (A_STRUCTURE)e.Value;
                }
                else if (e.Element == ExportElement.Cell
                    && e.Context is GridViewComboBoxColumn)
                {
                    if (_confToExport.SelectedConfiguration != null
                        && _confToExport.SelectedConfiguration.ID != -1)
                    {
                        e.Value = _confToExport.SelectedConfiguration.NAME;
                    }
                }
            }
    Thank you for your fast answer which also works very well, but I prefer enable row virtualisation ;).

    Have a nice day,

    Val

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Silverlight > GridView > bug when exporting radgridview with gridviewcomboboxcolumn
Related resources for "bug when exporting radgridview with gridviewcomboboxcolumn"

Silverlight Grid Features  |  Documentation  |  Demos  |  Telerik TV  |  Self-Paced Trainer  ]