Declined
Last Updated: 11 Aug 2021 08:26 by ADMIN
Philip
Created on: 18 Jul 2015 11:39
Category: Spreadsheet
Type: Feature Request
0
Hide/Disable Selection Capabilities for RadSpreadsheet
Can we have the ability to hide the cell selector rectangle in the RadSpreadsheet? If we had this, along with the current existing functionality we would have spreadsheet capabilities inside what looks like an 'empty' page. It would be good for reporting purposes where the developer can make full use of the spreadsheet's functions but completely hide the 'spreadsheet look-and-feel' from the user.
4 comments
ADMIN
Dimitar
Posted on: 11 Aug 2021 08:26

Hello Robby,

I want to suggest an alternative solution. You can use the SelectionChanging event in order to cancel the selection if it is disabled and allow it if enabled. Here is a sample implementation of this: 

bool selectionEnabled = true;
private void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
    Selection selection = this.radSpreadsheet.ActiveWorksheetEditor.Selection;
    selection.SelectionChanging += Selection_SelectionChanging;
}

private void Selection_SelectionChanging(object sender, SelectionChangingEventArgs e)
{
    if (!selectionEnabled)
    {
         e.Cancel();
    }
}

private void Button_Click(object sender, RoutedEventArgs e)
{
    if (selectionEnabled)
    {
        Selection selection = this.radSpreadsheet.ActiveWorksheetEditor.Selection;
        selection.Select(0, 0, 0, 0, true);
        selectionEnabled = false;
    }
    else
    {
        selectionEnabled = true;
    }
}

I have tested this with the UI layers but at this point, our public API does not allow adding new layers once the control is initialized. You can create a custom layer and disable the selection inside it: 

public partial class MainWindow : Window
{
    CustomUILayerBuilder builder = new CustomUILayerBuilder();
    public MainWindow()
    {
        InitializeComponent();
      

        this.radSpreadsheet.WorksheetUILayersBuilder = builder;
    } 
    private void Button_Click(object sender, RoutedEventArgs e)
    {
        if (builder.Layer.EnableSelection)
        {
            builder.Layer.Clear();
            builder.Layer.EnableSelection = false;
        }
        else
        {
            builder.Layer.EnableSelection = true;
        }        
    }
}

public class CustomUILayerBuilder : WorksheetUILayersBuilder
{
    public CustomSelectionUILayer Layer { get; private set; }

    public override void BuildUILayers(UILayerStack<WorksheetUILayerBase> uiLayers)
    {
        base.BuildUILayers(uiLayers);
        this.Layer = new CustomSelectionUILayer();
        uiLayers.Remove(WorksheetPredefinedUILayers.Selection);
        uiLayers.AddBefore(WorksheetPredefinedUILayers.CellInput, this.Layer);
    }
}
public class CustomSelectionUILayer : SelectionUILayer
{
    public bool EnableSelection { get; set; }

    public override void UpdateUIOverride(WorksheetUIUpdateContextBase updateContext)
    {
        if (this.EnableSelection)
        {
            base.UpdateUIOverride(updateContext);
        }      
    }

I hope this helps. Should you have any other questions do not hesitate to ask.

Regards,
Dimitar
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Robby
Posted on: 10 Aug 2021 13:40

Hi,

How van you toggle between showing and hiding the cell selection?

I have tried to add the selection layer again:

_uiLayers.AddLast(new SelectionUILayer());

also resetting the default layer class does not work:

radSpreadsheet.WorksheetUILayersBuilder = new WorksheetUILayersBuilder();

 

ADMIN
Petya
Posted on: 10 Aug 2015 08:40
Hi Philip,

We haven't heard back from you, so I'm going to decline this item. Hopefully, my suggestion helped you achieve the desired result. If this is not the case, please provide us with the requested images showing the expected look of the control.
ADMIN
Petya
Posted on: 23 Jul 2015 15:59
Hello Philip,

Disabling the visual representation of the selection is already possible by removing the UI layer responsible for it. For this purpose, you'll need to create a new layers builder and assign it to RadSpreadsheet.
    this.radSpreadsheet.WorksheetUILayersBuilder = new CustomUILayerBuilder();

    public class CustomUILayerBuilder : WorksheetUILayersBuilder
    {
        public override void BuildUILayers(UILayerStack<WorksheetUILayerBase> uiLayers)
        {
            base.BuildUILayers(uiLayers);
            uiLayers.Remove(WorksheetPredefinedUILayers.Selection);
        }
    }

I'm not entirely sure I understand your scenario, however. If this doesn't fit your needs, could you attach some images showing what you are trying to achieve?