Datagrid cell restrictions
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Datagrid cell restrictions
Hi all
Could someone tell me if it is possible to restrict what a user can enter in a cell within a data grid. Basically there is 1 column in my table that a user must complete manually or by uploading a CSV.
However, in this column there must be no more than 11 numbers entered. I want an error message or some form of control that does not allow users to enter more than 11 numbers (or any text at all) and also will not allow a user to go to the 'next stage' if less than 11 characters are added (or text is added)
Help is greatly appreciated.
Could someone tell me if it is possible to restrict what a user can enter in a cell within a data grid. Basically there is 1 column in my table that a user must complete manually or by uploading a CSV.
However, in this column there must be no more than 11 numbers entered. I want an error message or some form of control that does not allow users to enter more than 11 numbers (or any text at all) and also will not allow a user to go to the 'next stage' if less than 11 characters are added (or text is added)
Help is greatly appreciated.
Re: Datagrid cell restrictions
The datagrid is just a bunch of groups of ordinary LC objects, magically organized.
But the entry field is just that, a field called, I think, "dataGridFieldEditor", and generates "rawKeyDown", "keyDown" and other typical messages.
You can trap these and validate the data in any way you want. Limiting to 11 chars is a cakeWalk.
Craig Newman
But the entry field is just that, a field called, I think, "dataGridFieldEditor", and generates "rawKeyDown", "keyDown" and other typical messages.
You can trap these and validate the data in any way you want. Limiting to 11 chars is a cakeWalk.
Craig Newman
Re: Datagrid cell restrictions
Thats great thanks Craig. I have the following code that works as wanted in a normal field:
I am just not sure where to put this code within the data grid...
Code: Select all
on keyDown theKey
if the length of me >= 10 then
## The maximum length has been reached
## keyDown is not passed so the key is not entered into the field
beep
else
## The maximum length has not been reached
## keyDown is passed and the key is entered into the field
pass keyDown
end if
end keyDown
Re: Datagrid cell restrictions
Its that magic thing.
If you create a new datagrid, all you get is a bunch of groups and graphics. If you create a column or two, you suddenly find yourself with a bunch of fields. If you place data in some of the cells, you get even more fields.
On a blank card, place a datagrid. Add a column or two. Put some data in the contents pane.
In the card script, or in the master group script of the dg, put
Target is a temporary editable field (field "DataGridFieldEditor") that is ephemeral. The dg creates and locates it as needed, overlying the cell of interest, and losing it when it is finished. (This info is all thanks to Jacque (who else?))
Craig Newman
If you create a new datagrid, all you get is a bunch of groups and graphics. If you create a column or two, you suddenly find yourself with a bunch of fields. If you place data in some of the cells, you get even more fields.
On a blank card, place a datagrid. Add a column or two. Put some data in the contents pane.
In the card script, or in the master group script of the dg, put
Code: Select all
on keydown
if the length of target > 11 then exit to top -- or whatever...
pass keydown
end keydown
Craig Newman
Re: Datagrid cell restrictions
Aaaah now thats great, but what if the rule should only apply to 1 column named 'MobileNumber' for instance?
Re: Datagrid cell restrictions
I am not a DG expert. But I know there must be gadgets that will tell you what you need. This likely will go behind the back of the workaround I proposed.
Check out the large DG manual available from RR. The info is certainly there.
Craig Newman
Check out the large DG manual available from RR. The info is certainly there.
Craig Newman
Re: Datagrid cell restrictions
Thanks Craig for you help.
I have trawled through the manual and searched high and low on the web and I still can't work it out for the life of me.
Can anyone else shed any light on this?
I have trawled through the manual and searched high and low on the web and I still can't work it out for the life of me.
Can anyone else shed any light on this?
-
- Posts: 919
- Joined: Wed Nov 04, 2009 11:41 am
Re: Datagrid cell restrictions
Bump 3 years...... have passed,
Was an answer found ? I am trying to do similar with a datagrid.
Simon K
Was an answer found ? I am trying to do similar with a datagrid.
Simon K
best wishes
Skids
Skids