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

Scrollbar Event

6 Answers 129 Views
GridView
This is a migrated thread and some comments may be shown as answers.
jbaird
Top achievements
Rank 1
jbaird asked on 29 Jun 2009, 06:08 PM
How do you access the events around scolling in the radGridView?

I have a combobox usercontrol in a grid that looses its binding whenever the scrollbar is moved.  I need to trap the event to reconfigure the combobox..

thanks..

6 Answers, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 30 Jun 2009, 10:38 AM
Hello John,

I'm not sure that I have understood your question. Where is this ComboBox - in user control that is set as a CellEditTemplate or directly as GridViewComboBoxColumn? How did you specify this binding?
If you could send us a simple project demonstrating this issue it will be of great help.

If you need to handle scroll events you can do it in by finding the GridViewScrollViewer and attach handlers to HorizontalScrollChanged or VerticalScrollChanged.
Finding the GridViewScrollViewer can be done if you call this.ParentOfType<GridViewScrollViewer>() method in Loaded event handler of your user control.

I'm waiting for your response.

All the best,
Hristo
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
jbaird
Top achievements
Rank 1
answered on 30 Jun 2009, 01:03 PM
I followed your suggestions in a previous support request to create a user control containing a combobox and use the celledittemplate to place that control into the radgrid.  I had to do this because I require each combobox to have a different itemsource depending on a selection from a tree view control. 

When a selection is made in the treeview, an asynch event calls to the datalayer to retrieve the requested information and in a call back method I update the comboboxes itemssource to the correct list of elements.  The problem is that whenever the grid is scrolled, sorted, etc, the combo box blanks out and looses its itemssource definition.  I have to requery the database at that point to reinitialize the combobox so that the information reappears.  When the scrollbar is used, any of the combos that get scrolled up or down from the viewable section of the grid blank out.  The ones that remain visible in the grid, retain their information.

Our code is so complex, that I can't put together a sample to demonstrate the problem.
0
jbaird
Top achievements
Rank 1
answered on 30 Jun 2009, 01:15 PM
Here are the relevant code areas:
the user control:

 <UserControl x:Class="Bowne.AppModule.Common.GUI.Silverlight.FundSettingsEditPageComboBoxControl"

     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

     xmlns:bacgs="clr-namespace:Bowne.AppModule.Common.GUI.Silverlight"

     xmlns:bfgs="clr-namespace:Bowne.Framework.GUI.Silverlight;assembly=Bowne.Framework.GUI.Silverlight">

   
        <Grid x:Name="LayoutRoot">

           <bfgs:bRadComboBox x:Name="FundSettingsEditComboBox"></bfgs:bRadComboBox>   

       </Grid>

   </UserControl>




the usage:

   <bfgs:bGroupBox x:Name="grpCategoryTypes"

                   Header="Category Library"

                   Grid.ColumnSpan="2"

                   Grid.Row="1">

      <bfgs:bGrid>

         <bfgs:bRadGridView x:Name="grdCategory"

                            AutoGenerateColumns="False"

                            ColumnsWidthMode="Fill"

                            IsReadOnly="False"

                            CanUserReorderColumns="False"

                            CanUserFreezeColumns="False"

                            ShowGroupPanel="False"

                            telerik:StyleManager.Theme="">

               <bfgs:bRadGridView.Columns>

                  <twcg:GridViewDataColumn  HeaderText="Category Type Name"

                                            IsReadOnly="True"

                                            Width="400"

                                            DataMemberBinding="{Binding CategoryTypeName}" />

                       <twcg:GridViewDataColumn HeaderText="Category Library">

                           <twcg:GridViewDataColumn.CellTemplate>

                               <DataTemplate>

                                   <bacgs:FundSettingsEditPageComboBoxControl />

                               </DataTemplate>

                           </twcg:GridViewDataColumn.CellTemplate>

                       </twcg:GridViewDataColumn>  

                </bfgs:bRadGridView.Columns>

            </bfgs:bRadGridView>

       </bfgs:bGrid>

   </bfgs:bGroupBox>

the binding:

        /// <summary>

        /// Set the items source on combo based on categorytype key

        /// </summary>

        public void SetComboBoxItemSource()

        {

            int? catTypeKey = ((FundCategoryLibraryDataObject)this.DataContext).FK_CategoryType;

            int? catLibKey = ((FundCategoryLibraryDataObject)this.DataContext).FK_CategoryLibrary;

            string catLibName = ((FundCategoryLibraryDataObject)this.DataContext).CategoryLibraryName;

            if (catLibKey == null)

            {

                catLibKey = 0;

            }

            List<CategoryLibraryObject> list = this.GetCategoryLibrariesByCategoryTypeKey(catTypeKey);

            this.FundSettingsEditComboBox.ItemsSource = null;

            this.FundSettingsEditComboBox.ItemsSource = list;

 

            this.FundSettingsEditComboBox.DisplayMemberPath = "CategoryLibraryName";

            this.FundSettingsEditComboBox.SelectedValuePath = "CategoryLibraryKey";

            this.FundSettingsEditComboBox.SelectedValue = catLibKey;

            ((FundCategoryLibraryDataObject)this.DataContext).EnablePropertyChangedEvent = true;

        }

Hope this helps...

0
Hristo
Telerik team
answered on 30 Jun 2009, 04:13 PM
Hi John,

The xaml snippet was not enough to rebuild your project but I've prepared a simple application demonstrating how to set UserControl on CellEditTemplate and bind it to the data.

Please take a look at the attached project and let me know if this will help you (you need to add the missing assemblies).

All the best,
Hristo
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
jbaird
Top achievements
Rank 1
answered on 30 Jun 2009, 05:58 PM
Hristo,

I have created a support ticket and enclosed a zip file with the relevant files so you can see what we're trying to do....
0
Chris Foti
Top achievements
Rank 1
answered on 13 May 2011, 09:04 PM
Is there any news regarding this, I'm running into the same issue...

In my xaml I have added a grid -

 

 

 

<telerikGrid:RadGridView HorizontalAlignment="Center" Margin="8" IsEnabled="{Binding StatesEnabled}" l:RadGridViewColumnsBinding.ColumnsCollection="{Binding Path=GridColumnData}" SelectionMode="Single"

 

 

 

 

VerticalAlignment="Center" ItemsSource="{Binding States, Mode=TwoWay}" Height="400"

 

 

 

x:Name="ScreenGrid" AutoGenerateColumns="False" IsReadOnly="False" ColumnWidth="*" CanUserDeleteRows="False" CanUserInsertRows="False" EditTriggers="CellClick" EnableColumnVirtualization="True" EnableRowVirtualization="True">

 



The RadGridViewColumnsBinding.ColumnsCollection is a dependency property that binds to a collection and dynamically sets the grid's columns at runtime. Depending on what a user does in the application, the columns change to present them with different options, which is why I'm doing this.

This part of my code works fine, I'm able to successfully create the columns at runtime and all work correctly expect for a column whose CellEditTemplate I am setting to this -

<

 

 

DataTemplate x:Name="ExistingWritingCompanyTemplate">

 


<

 

 

ComboBox ItemsSource="{Binding ExistingWritingCompanies}" IsEnabled="{Binding HasExistingWritingCompanies}" SelectedItem="{Binding SelectedExistingWritingCompany, Mode=TwoWay}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">

 

 

 

 

</ComboBox>

 

 

 

 

</DataTemplate>

 



The above snippet I have in a Resource Dictionary that gets read when I am creating the columns. I am doing this for every column I create but I'm only having an issue with this one as this is the only column that I have a combo box in.

The column gets created correctly and the ItemsSource for the combo box gets set properly, I am able to see all the expected options in the combo box. The issue I have is that if a choose a value from the combo box, and then scroll up / down through the grid, as soon as the row containing the combo box that I made a selection on is no longer visible, the SelectedItem is set to null. The ItemsSource is still set correctly and I can go back and make a selection again, but again it dissappears after it is no longer visible...

I have found that if I set EnableRowVirtualization on the Grid to "False" everything works correctly and the SelectedItem properly stays set properly. The only issue with doing this is the grid becomes very unresponsive and jerky and takes a bit to load.

Any thoughts on this? I am using the 2010.2.812.1040 version of the Telerik.Windows.Controls.GridView.dll. I am strictly following the MVVM pattern while developing this application, so solutions using code behind aren't usable. Again, everything I am doing is working perfectly for me except when it comes to the ComboBox, so I believe the issue has something to do with the combo box and Virtualization...

One other minor issue that I haven't had a chance to look much into, but I'm trying to enable / disable the combo box in the column for certain rows (not trying to disable the column as a whole). So in my above template the I am using for the CellEditTemplate I am trying to bind the combo box's IsEnabled propertly to a propertly in the object I'm binding the other combo box stuff to.

IsEnabled="{Binding HasExistingWritingCompanies}"

The property in the object is being set properly, but the combo box isn't enabling / disabling properly, the combo box is ALWAYS enabled. Even if a explicitly set the IsEnabled property to "False" in the datatemplate, the combo boxes are still ALWAYS enabled.

IsEnabled="False"
Tags
GridView
Asked by
jbaird
Top achievements
Rank 1
Answers by
Hristo
Telerik team
jbaird
Top achievements
Rank 1
Chris Foti
Top achievements
Rank 1
Share this question
or