|
Rank: Member Groups: Member
Joined: 12/2/2010 Posts: 10
|
Hi, I am trying to work with adding a new item when the grid is set AllowNewItem=true. I need two of the columns currently displayed to be excluded from the user being able to enter values into them. I need these columns to be editable after the row is added but I want to control the values entered
columns on grid ID (RowNumberColumn) FormName (TextBoxColumn) Changed By User (StaticColumn) Changed By Date (DateTimeColumn)
What I would like to have:
columns available on add new item line. formName (TextBoxColumn)
I searched on the forum and looked at available properties but nothing jumped out at me either there on in the examples.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
You won't be able to have different column types on different rows. What you can do is to handle the column's ClientSideBeginEdit on your column (the property takes a JavaScript function name) and then return false from your handler to prevent the cell from entering edit mode.
Thanks!
|
|
Rank: Member Groups: Member
Joined: 12/2/2010 Posts: 10
|
Thanks for the quick reply.
Just so I understand, what you are saying is that if you use the default AllowNewItem with the add row at the bottom, you cannot make one of those columns read-only if the column in the rest of the grid is editable ? With the ClientSideBeginEdit, how to determine that the column is coming from the NewItem row and not from a row already added into the grid where I want to allow the column to be edited ?
If this isn't an option, can you use an ItemTemplate to build an add form below the grid and fire the OnItemAdded to the grid ?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
Whatever you set on the column applies to the whole column. There is no additional settings for a column that would apply differently on different row. So AllowNewItem is irrelavent in this logic.
The GridCell object is passed to your ClientSideBeginEdit handler. You can get the GridItem object from the cell object, then get the item index from the GridItem object. You can then compare the item index against your original item count to see whether this is a new item or not.
It is also OK if you wish to build an add form below the Grid. However that template would not have anything to do with the Grid. It is possible for you to call Grid's client side addItem to add new item to the Grid thus fires OnItemAdded event, but you will have to write the code to wire these two pieces together. Otherwise the Grid is the Grid and your ItemTemplate is your ItemTemplate and they would not have anything to do with each other.
Thanks!
|
|