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

Worksheet scrolling while IsEnabled = false

6 Answers 125 Views
Spreadsheet
This is a migrated thread and some comments may be shown as answers.
Rod
Top achievements
Rank 1
Rod asked on 03 Sep 2014, 08:53 PM
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.

6 Answers, 1 is accepted

Sort by
0
Rod
Top achievements
Rank 1
answered on 04 Sep 2014, 05:58 PM
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)

0
Anna
Telerik team
answered on 05 Sep 2014, 12:06 PM
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.
 
0
Rod
Top achievements
Rank 1
answered on 05 Sep 2014, 12:40 PM
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.

0
Anna
Telerik team
answered on 08 Sep 2014, 11:03 AM
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.
 
0
Rod
Top achievements
Rank 1
answered on 08 Sep 2014, 05:47 PM
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 );
           }

0
Anna
Telerik team
answered on 09 Sep 2014, 01:11 PM
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.
 
Tags
Spreadsheet
Asked by
Rod
Top achievements
Rank 1
Answers by
Rod
Top achievements
Rank 1
Anna
Telerik team
Share this question
or