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

Need Scrollbars enabled while RadGridView is disabled "part 2"

14 Answers 202 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Terje Johansen
Top achievements
Rank 1
Terje Johansen asked on 15 Sep 2011, 12:59 PM
Hi, 

I have a grid that is shown in two different windows...(different windows same grid)
In one of the windows the grid is enabled and the user can edit the grid, but in the other window the grid is disabled.
My problem is that the grid scrollbar is disabled in the window where the grid is disabled...

I read the thread (hence the title on this post) on the forum about someone with a similar issue, but the solution for 
that case, a style targeting the GridViewRow, will not help me I'm afraid.

Is there another way to disable the grid but not the scroll?

Please advice!

14 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 20 Sep 2011, 03:45 PM
Hello Terje Johansen,

 You could set your GridView to be ReadOnly. That way editing the data is disabled, but you still may benefit from the other functionality of the RadGridView.

Would this approach be good for your case?

Greetings,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Terje Johansen
Top achievements
Rank 1
answered on 26 Oct 2011, 02:40 PM
No, because even if I set it to ReadOnly you can still open up context menues and insert rows **
unless I add a lot of extra checks all over the place to see if grid is readonly or not.
By setting "grid.IsEnabled = false" I avoid all this 

** e.g. Keyboard Insert will insert a new row because it's the same grid in both windows and this may have been enabled when first opened
0
Terje Johansen
Top achievements
Rank 1
answered on 20 Mar 2012, 02:40 PM
Hi !

Any news/other suggestions regarding my problem or how I can solve it ?
0
Vlad
Telerik team
answered on 20 Mar 2012, 02:46 PM
Hello,

 I'm afraid that we do not have any other suggestions. 

Regards,
Vlad
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Stacy
Top achievements
Rank 1
answered on 25 Jan 2013, 05:46 PM
I am using a RadGrid and want my scrollbar to be enabled when i disable the grid. 

1.  How can I do this?
2.  Why would disabling the scroll be the default for the RadGrid, many people need it enabled.
0
Terje Johansen
Top achievements
Rank 1
answered on 28 Jan 2013, 07:21 AM
The following code solved the problem for me:

Add styles:
       <!--Disabled row in RadGridView-->
	<Style x:Key="DisabledRow" TargetType="{x:Type GridView:GridViewRow}">
		<Setter Property="IsEnabled" Value="False" />
	</Style>
 
	<!--Enabled row in RadGridView -->
	<Style x:Key="EnabledRow" TargetType="{x:Type GridView:GridViewRow}">
		<Setter Property="IsEnabled" Value="True" />
	</Style>
Use styles in your code (ViewModel):
//Original values
    var canDelete = View.GebyrGrid.CanUserDeleteRows;
    var canInsert = View.GebyrGrid.CanUserInsertRows;
 
   if (perform check to see if grid should be disabled or enabled )
   {	
         // disable grid 
        View.GebyrGrid.RowStyle = (Style)Application.Current.MainWindow.FindResource("DisabledRow");
	View.GebyrGrid.CanUserDeleteRows = false;
	View.GebyrGrid.CanUserInsertRows = false;     
        View.GebyrGrid.Tag = "DisabledRow";         
}
else   {       // enable grid View.GebyrGrid.RowStyle = (Style)Application.Current.MainWindow.FindResource("EnabledRow"); View.GebyrGrid.CanUserDeleteRows = canDelete; View.GebyrGrid.CanUserInsertRows = canInsert;
    View.GebyrGrid.Tag = "EnabledRow";
} //if you have a contextmenu it too must be disabled (
code-behind file)
private void GebyrGridOpened(object sender, RoutedEventArgs e)
        {
            if (Equals(GebyrGrid.Tag, "DisabledRow"))
            {
                ((RadContextMenu)sender).IsEnabled = false;
                return;
            }
          
            ((RadContextMenu)sender).IsEnabled = true;
}
0
Stacy
Top achievements
Rank 1
answered on 28 Jan 2013, 12:58 PM
I am not looking to disable each row.  I want the grid disabled but I want customers to be able to scroll and see what information is available.
0
Terje Johansen
Top achievements
Rank 1
answered on 28 Jan 2013, 02:46 PM
I think that this is the only way you can achieve what you want....
to disable the grid, but still have scrollbars that works you have to disable each row as shown in the code-example I posted.


0
Stacy
Top achievements
Rank 1
answered on 31 Jan 2013, 02:25 PM
I think telerik needs to make this part of their control as many people are asking for it
0
Stacy
Top achievements
Rank 1
answered on 31 Jan 2013, 02:54 PM
Where is the "style" xml placed?
0
Terje Johansen
Top achievements
Rank 1
answered on 01 Feb 2013, 07:04 AM
I have a separate xaml file for all my Telerik styles and refer to them as DynamicResource, but you can also place the two styles in the xaml file where your grid is (as Resources) and refer to them as StaticResource
0
Stacy
Top achievements
Rank 1
answered on 06 Feb 2013, 06:03 PM
I haven't been able to place these style tags in the aspx where my grid is, is that not possible?  I am using a RadGrid.
0
Terje Johansen
Top achievements
Rank 1
answered on 07 Feb 2013, 07:22 AM
You might need a different syntax/approach for aspx (ASP.NET) files.
I'm using xaml files (WPF).
 
0
Arseni
Top achievements
Rank 1
Iron
answered on 08 Feb 2024, 09:38 AM
You can just wrap your radgridview in grid and ScrollViewer


like this
<Grid>
    <ScrollViewer VerticalScrollBarVisibility="Visible" CanContentScroll="True" >
        <telerik:RadGridView
                     ItemsSource="{Binding Parameters, UpdateSourceTrigger=PropertyChanged}"
                     IsEnabled="False">
        </telerik:RadGridView>
    </ScrollViewer>
</Grid>

Tags
GridView
Asked by
Terje Johansen
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Terje Johansen
Top achievements
Rank 1
Vlad
Telerik team
Stacy
Top achievements
Rank 1
Arseni
Top achievements
Rank 1
Iron
Share this question
or