Worksheet scrolling while IsEnabled = false

7 posts, 0 answers
  1. Rod
    Rod avatar
    17 posts
    Member since:
    Jul 2014

    Posted 03 Sep 2014 Link to this post

    OK, I have an active sheet that is used for data entry.  Some cells are protected so they cannot enter data in them.

    Now, depending on the status of the item being viewed AND the security role of the user editing the data - the entire spreadsheet may or may not be enabled (IE View Only).  If I set IsEnabled = false on the entire spreadsheet control I cannot do anything with the spreadsheet scrolling related.

    Problem is, my active sheet has a lot of rows and columns in it and they still need to be able to scroll.

    I can set the ActiveWorksheetEditor.IsEnabled = false and it kinda works.  The scroll bars work if the user grabs the slider them and moves it up or down or they click on the scroll arrows.  BUT the mouse wheel doesn't work within the sheet itself. 

    Also, I am only able to set this property programmatically in the code behind - any way of getting it in the Xaml?  My spreadsheet contains 1 and only 1 worksheet.  I have the SheetSelector turned off.

    << Possibly put the radSpreadsheet inside a scroll viewer that is fixed height and then force the radspreadsheet control to consume all the space it needs when displayed (forcing it to exceed the scrollviewers viewport?>>
    Thanks.
  2. Rod
    Rod avatar
    17 posts
    Member since:
    Jul 2014

    Posted 04 Sep 2014 Link to this post

    In the forum post http://www.telerik.com/forums/protect-cell-or-sheet-in-spreadsheet it is mentioned that all the cells can be made "non editable' by removing the CellInput layer.

    Could this be used to resolve my issue above (I would hope for a more elegant solution but will take what I can get right now)

    I would need to access the 'uilayers' collection after initialization when the item I am editing has a status change  (to either add it to or remove it from the collection)

  3. UI for WPF is Visual Studio 2017 Ready
  4. Anna
    Admin
    Anna avatar
    99 posts

    Posted 05 Sep 2014 Link to this post

    Hi,

    Unfortunately, if you need to change the UILayersCollection after it has been initialized, this might not be the right approach for the case, because the collection is built only once.

    I am not sure that I understand your scenario entirely. Wouldn't it be possible to protect the sheet and then change the IsLocked property of the necessary ranges depending on the user's security level? If all cells are locked you would get a result essentially the same to removing the cell input layer.


    Regards,
    Anna
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
  5. Rod
    Rod avatar
    17 posts
    Member since:
    Jul 2014

    Posted 05 Sep 2014 in reply to Anna Link to this post

    I believe this is what I will need to do.

    In our use case, we have an item that is edited by people in multiple roles and it passes through a workflow where its status changes depending upon where its at in the workflow.   Our content also needs to be dynamic depending on the year.

    So our solution is that we have a xlsx spreadsheet template for a given year.  This template has 2 worksheets One for a contributor and one for an administrator that is essentially the same except for cell protection and the contributor sheet has a few hidden rows.  While the item is 'in progress' or under review'  it needs to be editable depending on the users role, but once approved it needs to be read only.

    Since the content can change from year to year (We retain one hidden column in the spreadsheet to associate a 'row' with database information)  we really want to minimize the amount of code logic needed for locking unlocking showing hiding and rather use the template to drive displayed data.

  6. Anna
    Admin
    Anna avatar
    99 posts

    Posted 08 Sep 2014 Link to this post

    Hello,

    I am not sure if setting the IsEnabled property or removing the input layer would reduce the logic sufficiently to justify using them. It seems that using the IsLocked property should be less problematic and more suitable in your case.

    Please, let us know in case you have any further concerns.

    Regards,
    Anna
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
  7. Rod
    Rod avatar
    17 posts
    Member since:
    Jul 2014

    Posted 08 Sep 2014 in reply to Anna Link to this post

    Anna,
      Would there be any issues with removing the CellInputLayer (and remembering it) and reinserting it into the UILayers stack at runtime?

    I made a small sample app that has a protect button containing the following code - and it provides the functionality I am needing.

    Rod

    if ( this.mySpreadsheet.ActiveWorksheetEditor.ActivePresenter.UILayers.Contains( WorksheetPredefinedUILayers.CellInput ) )
               {               
                   CellInputLayer = this.mySpreadsheet.ActiveWorksheetEditor.ActivePresenter.UILayers.GetByName(WorksheetPredefinedUILayers.CellInput);
                   this.mySpreadsheet.ActiveWorksheetEditor.ActivePresenter.UILayers.Remove(WorksheetPredefinedUILayers.CellInput);
               }
               else
               {
                   if ( CellInputLayer != null )
                       this.mySpreadsheet.ActiveWorksheetEditor.ActivePresenter.UILayers.AddLast( CellInputLayer );
               }

  8. Anna
    Admin
    Anna avatar
    99 posts

    Posted 09 Sep 2014 Link to this post

    Hi Rod,

    I believe it shouldn't be an issue. However, it is best to also add a check before removing the layer in case the active cell is in edit mode. If it is in edit mode the moment the layer is removed a null reference exception is thrown. Maybe this situation will not be possible in your scenario, but it's better to be on the safe side.

    Also, as the order of the UI layers is important, we should add the layer in its previous position, which is before the resize decoration layer. With these two in mind, the code should look similar to this:

    RadWorksheetEditor editor = this.radSpreadsheet.ActiveWorksheetEditor;
     
    if (editor.ActivePresenter.UILayers.Contains(WorksheetPredefinedUILayers.CellInput))
    {
        if (editor.Selection.ActiveCellMode != ActiveCellMode.Edit)
        {
            CellInputLayer = editor.ActivePresenter.UILayers.GetByName(WorksheetPredefinedUILayers.CellInput);
            editor.ActivePresenter.UILayers.Remove(WorksheetPredefinedUILayers.CellInput);
        }
    }
    else
    {
        if (CellInputLayer != null)
        {
            editor.ActivePresenter.UILayers.AddBefore(WorksheetPredefinedUILayers.ResizeDecoration, CellInputLayer);
        }
    }


    Regards,
    Anna
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
Back to Top
UI for WPF is Visual Studio 2017 Ready