Need Scrollbars enabled while RadGridView is disabled "part 2"

14 posts, 0 answers
  1. Terje Johansen
    Terje Johansen avatar
    28 posts
    Member since:
    Mar 2010

    Posted 15 Sep 2011 Link to this post

    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!
  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 20 Sep 2011 Link to this post

    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 >>

  3. UI for WPF is Visual Studio 2017 Ready
  4. Terje Johansen
    Terje Johansen avatar
    28 posts
    Member since:
    Mar 2010

    Posted 26 Oct 2011 Link to this post

    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
  5. Terje Johansen
    Terje Johansen avatar
    28 posts
    Member since:
    Mar 2010

    Posted 20 Mar 2012 Link to this post

    Hi !

    Any news/other suggestions regarding my problem or how I can solve it ?
  6. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 20 Mar 2012 Link to this post

    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 >>
  7. Stacy
    Stacy avatar
    98 posts
    Member since:
    Dec 2010

    Posted 25 Jan 2013 Link to this post

    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.
  8. Terje Johansen
    Terje Johansen avatar
    28 posts
    Member since:
    Mar 2010

    Posted 28 Jan 2013 Link to this post

    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;
    }
  9. Stacy
    Stacy avatar
    98 posts
    Member since:
    Dec 2010

    Posted 28 Jan 2013 Link to this post

    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.
  10. Terje Johansen
    Terje Johansen avatar
    28 posts
    Member since:
    Mar 2010

    Posted 28 Jan 2013 Link to this post

    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.


  11. Stacy
    Stacy avatar
    98 posts
    Member since:
    Dec 2010

    Posted 31 Jan 2013 Link to this post

    I think telerik needs to make this part of their control as many people are asking for it
  12. Stacy
    Stacy avatar
    98 posts
    Member since:
    Dec 2010

    Posted 31 Jan 2013 Link to this post

    Where is the "style" xml placed?
  13. Terje Johansen
    Terje Johansen avatar
    28 posts
    Member since:
    Mar 2010

    Posted 01 Feb 2013 Link to this post

    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
  14. Stacy
    Stacy avatar
    98 posts
    Member since:
    Dec 2010

    Posted 06 Feb 2013 Link to this post

    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.
  15. Terje Johansen
    Terje Johansen avatar
    28 posts
    Member since:
    Mar 2010

    Posted 07 Feb 2013 Link to this post

    You might need a different syntax/approach for aspx (ASP.NET) files.
    I'm using xaml files (WPF).
     
Back to Top
UI for WPF is Visual Studio 2017 Ready