Client-side SetLocked() method not working...

Posted by: rh0314 on 8 September 2017, 2:12 pm EST

  • Posted 8 September 2017, 2:12 pm EST

    following the example in the objectmodel.aspx page in the NewFeaturesDemo solution, I am trying to set the locked property of a cell to true using client side-script.  However, whenever I try to run it, i receive an error, "Object doesn't support this property or method."


     Here's the javascript code:


    <FONT size=2> 


    </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>function</FONT></FONT><FONT size=2> DisableCell(Row, Col) {


    </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>var</FONT></FONT><FONT size=2> spread = document.getElementById(</FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>"ctl00_BodyContent_FpSpread1"</FONT></FONT><FONT size=2>);


    </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>if</FONT></FONT><FONT size=2> (spread != </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>null</FONT></FONT><FONT size=2>) {

    </FONT><FONT size=2>

    </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>var</FONT></FONT><FONT size=2> cell = spread.Cells(Row, Col);


    </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>if</FONT></FONT><FONT size=2> (cell) {


    </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>if</FONT></FONT><FONT size=2> (cell.GetBackColor() != </FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>"red"</FONT></FONT><FONT size=2>) cell.SetBackColor(</FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>"red"</FONT></FONT><FONT size=2>);

    </FONT><FONT size=2>

    if (!cell.GetLocked()) <FONT style="BACKGROUND-COLOR:#ffff33;">cell.SetLocked(</FONT></FONT><FONT color=#0000ff size=2><FONT style="BACKGROUND-COLOR:#ffff33;" color=#0000ff size=2>false</FONT></FONT><FONT size=2><FONT style="BACKGROUND-COLOR:#ffff33;">);</FONT>


    }


    }


    }


     


    The portion highlighted in yellow is the part that produces the error.  What am I doing wrong here??  It seems like I'm following the example exactly.

    </FONT>
  • Replied 8 September 2017, 2:12 pm EST

    Hi, to set a cell Locked (or unlocked), you should use the following code at client side:

    <code - lock>

    cell.setAttribute("FpCellType", "readonly");

    </end of code - lock>

    <code - unlock>

    cell.removeAttribute("FpCellType");

    </end of code - unlock>

    Please note that spread.Cells(Row, Col) returns TD element in HTML.

    Thanks,

    ~Jacob 

Need extra support?

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

Learn More

Forum Channels