locked
Disable New Row in Lightswitch Datagrid RRS feed

  • Question

  • I have removed the Add button from a Lightswitch datagrid CommandBar.  I need to disable the ability to enter a new row at the bottom of the datagrid.  I cannot set the datagrid to readonly because I need to edit fields in the pre-populated rows.

    Access to the control or backing dataview is not obvious.  Is there some way to access the "AllowNew" property?

    Thursday, November 4, 2010 12:12 PM

Answers

  • Dave VB,

    The way you remove the "enter new row at the bottom of the datagrid" is to mark the Data Grid as "Use Read-only Controls" in the Properties sheet.  Each cell will still be editable, since they are Text Boxes, but the Data Grid itself won't have a template row at the bottom.

    Make sure to mark the Data Grid as "Use Read-only Controls", and leave the Data Grid Row with "Use Read-only Controls" not checked.

    Eric

    Thursday, November 4, 2010 1:09 PM

All replies

  • Hi Dave.

    I think you have 2 way for this senario :

    1- Using Search Screan for the entity, and add a edit button to datagrid.

    2- solve this problems with security Methods on screen...


    Naser Papi
    Thursday, November 4, 2010 12:49 PM
  • Dave VB,

    The way you remove the "enter new row at the bottom of the datagrid" is to mark the Data Grid as "Use Read-only Controls" in the Properties sheet.  Each cell will still be editable, since they are Text Boxes, but the Data Grid itself won't have a template row at the bottom.

    Make sure to mark the Data Grid as "Use Read-only Controls", and leave the Data Grid Row with "Use Read-only Controls" not checked.

    Eric

    Thursday, November 4, 2010 1:09 PM
  • If you are feeling lucky - try the solution that I posted here - http://social.msdn.microsoft.com/Forums/en-US/lightswitchgeneral/thread/bc77c2af-b8f7-4c71-9e3f-07b61ac7c252. It worked like a charm for me (I removed the add new row and kept the rest of the data grid as editable.
    Norm Estabrook
    Thursday, November 4, 2010 6:12 PM
  • Thanks to all for your prompt replies.

    Eric, your suggestion seems to work like a champ.  Thanks.

    Norm, I looked at your suggestion and did not experience the issue that required coding when applying the "Use Read Only Controls" the way Eric suggested. 

    Again, thanks to all!

    Friday, November 5, 2010 11:53 AM