We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Protect Cell(s) from Server Side Code?

Hi, is there a way to set the protection of a cell from the server side code?  I see in the client code you can do .lockCell, however I need to protect cells from the server.  I have a routine that reads all the properties of a cell from a sql table to a model in the view and would like to protect the cell if required in the server code as I am adding the cells dynamically in the view

Thank you for any help

Regards,
Shawn

7 Replies

SI Silambarasan I Syncfusion Team September 30, 2016 01:02 PM UTC

Hi Shawn, 
 
Thank you for using Syncfusion products. 
 
Your requirement “To set the protection of a cell from server side code” can be achieved by using “IsLocked” property in Spreadsheet.  Please refer the following code example. 
 
CONTROLLER 
 
public ActionResult SpreadsheetFeatures() 
{ 
    List<Sheet> sheets = new List<Sheet>(); 
    WorkbookProperties workbook = new WorkbookProperties() 
    { 
        //... 
        Sheets = sheets 
    }; 
 
    sheets.Add(new Sheet() 
    { 
        Rows = new List<Row>() 
        { 
            new Row()  
            { 
                Index = 0, //Row index 
                Cells = new List<Cell>() 
                {  
                    new Cell() { Value = "Item Name", IsLocked =  true }, 
                    new Cell() { Value = "Quantity", IsLocked =  true }, 
                    //... 
                } 
            }, 
            //... 
        } 
    }); 
 
    ViewData["spreadsheetModel"] = workbook; 
    return View(); 
} 
 
 
VIEW 
 
<div class="control"> 
    @(Html.EJ().Spreadsheet<object>("FlatSpreadsheet", (WorkbookProperties)ViewData["spreadsheetModel"])) 
</div> 
 
 
 
For your convenience, we have prepared a sample to demonstrate this and the same can be downloaded from below link, 
 
Regards, 
Silambarasan I 



SW shawn walsh September 30, 2016 01:50 PM UTC

Perfect!!!!  This is exactly what I was hoping for!

Many, many thanks.   I am loving these components.

Best Regards,
Shawn


SI Silambarasan I Syncfusion Team October 3, 2016 12:21 PM UTC

Hi Shawn, 
 
Thanks for your update. 
 
We are happy to hear that your requirement has been achieved.  
Kindly get back to us if you need further assistance.  We will be happy to help you out. 
 
Regards,  
Silambarasan I 



SW shawn walsh October 5, 2016 02:25 PM UTC

Hi Silambarasan, I finally got around to downloading and trying out the sample on my dev machine.  I am getting the error 'Cell does not contain a definition for "IsLocked" in the controller.  This is occurring on both the sample you sent and my project.  Is this an issue with the Syncfusion nuget package versions, or my local installed Syncfusion components in the GAC? 

Any help is appreciated.

Regards,
Shawn


SI Silambarasan I Syncfusion Team October 6, 2016 12:35 PM UTC

Hi Shawn, 
 
Thanks for your update. 
 
We have checked the reported issue “Cell does not contain a definition for ‘IsLocked’ in controller” and we suspect that the cause of this issue is due to missing assembly references of required Essential Studio product version.  So, could you please ensure the following cases. 
 
1.  The referenced “Syncfusion” assemblies should be from “v14.2.0.28” or higher version [v14.3.0.49] since the ‘IsLocked’ property is available from Essential Studio 2016 Vol 2 SP1 v14.2.0.28 release onwards. 
 
2.  You should refer the same .NET Framework version for all our DLL references in your project. Example, if you refer the “Syncfusion.EJ.Export.dll” (v14.3400.0.49) in 4.0 .NET Framework its dependency “Syncfusion.EJ.dll” (v14.3400.0.49) should be referred with the same framework version. 
 
3.  You should refer the proper DLL’s version that targets the same .NET Framework version. Example, the “Syncfusion.EJ.dll” (v14.3400.0.49) reference should targets the .NET 4.0 Framework only.  
 
 
Could you please ensure the above cases and get back to us with more information such as current ES product version, installed Syncfusion NuGet package version if the issue still persists?  So, that we could able to sort out the cause of this issue and provide you a better solution quickly. The information provided would be great help for us to proceed further. 
 
 
Regards, 
Silambarasan I 



SW shawn walsh October 12, 2016 11:00 AM UTC

Hi Silambarasan ,

Thank you for the great detailed information.  I was able to get it working thanks to your example.  In my case it was still not working even though I had updated to 14.3.   Turned out I was missing some of the css and jquery files that were in your _Layout.cshtml file.  Going through them one by one got it to work.  Thanks for your outstanding assistance. 

Best Regards,
Shawn


SI Silambarasan I Syncfusion Team October 13, 2016 07:22 AM UTC

Hi Shawn, 
 
Thanks for your update.  We are happy to hear that your issue has been resolved. 
Kindly get back to us if you need any further assistance. 
 
Regards, 
Silambarasan I 


Loader.
Live Chat Icon For mobile
Up arrow icon