Row/Column locking not working properly

Posted by: joni.dewinter on 14 September 2021, 9:03 pm EST

  • Posted 14 September 2021, 9:03 pm EST

    Hello

    We're trying to lock rows and columns in Spread.NET V14 in an ASP.NET MVC 5 application.
    According to the documentation (https://www.grapecity.com/spreadnet/docs/v14/online-asp/FarPoint.Web.Spread~FarPoint.Web.Spread.Row~Locked.html), it requires the SheetView's Protect-property to be true (default), and no conflicting style should be assigned to the cells.
    We think all preconditions are met, but still the rows and columns are editable by the user.
    We tried the exact example from the documentation, but no success.

    var myrow = FpSpread1.ActiveSheetView.Rows[1, 3];
    myrow.HorizontalAlign = HorizontalAlign.Right;
    myrow.VerticalAlign = VerticalAlign.Top;
    myrow.Locked = true;


    We could workaround this by locking the individual cells (which does work), but we'd prefer to do this on entire rows and columns.
    Could you help us out?
    Thanks in advance!
  • Replied 16 September 2021, 4:24 pm EST

    Hi,

    We are sorry but we are unable to replicate the issue at our end. Could you please share a small sample that replicates the issue so that we could investigate it further and assist you accoridngly?

    Regards,
    Avinash
  • Replied 16 September 2021, 6:21 pm EST

    Hello Avinash

    While creating a clean solution to illustrate the problem to you, we found the actual cause.
    In our application, we explicitly set the Locked-property on certain cells to false (even when they were already false).
    Afterwards, we set the Locked-property on certain rows and columns.
    Example:

    FpSpread1.ActiveSheetView.Cells[1, 1].Locked = false;
    var myrow = FpSpread1.ActiveSheetView.Rows[1, 3];
    myrow.HorizontalAlign = HorizontalAlign.Right;
    myrow.VerticalAlign = VerticalAlign.Top;
    myrow.Locked = true;

    Apparently, the latter doesn't overrule the former.
    Could you confirm if this is working as designed?
    We assumed the row/column locked state would always overrule the cell locked state, but it seems to be the other way around.
    We did not find anything about this in the documentation.

    Kind regards
    Joni
  • Marked as Answer

    Replied 19 September 2021, 5:48 pm EST

    Hi Joni,


    Yes, this is by design, Cell level styles have greater priority than row-level styles so if we set the Locked to cell level then setting the property on row level does not override the cell level property.

    I hope this clarifies the issue.

    Regards,
    Avinash
  • Replied 19 September 2021, 6:03 pm EST

    Hello Avinash

    Thanks for the clarification, I'll mark your post as the answer.
    For our use case, we achieved the desired result by only setting the Locked-property to true for cells which actually have to be locked.

    Kind regards
    Joni
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels