View Full Version : Grid and Arrays...?

27 Apr 2010, 9:09 AM
I'm using a ColdFusion cfgrid, which I believe is the ExtJS Grid. I'm not great w/javascript and am having some issues figuring out how to go about this...

My grid (name = "locGrid") has two main columns: COUNTY and STATE.
COUNTY contains a 5 digit unique id.
State displays state name but the value underneath it is a two-digit code.
ex... 01 = AL. If a county is in AL, the first two digits are 01xxx.

The county field happens to be a drop-down box containing all US counties.
I want to make sure that when the user selects a county, they are only picking one that matches it's associated State.

1) I think I might need some sort of array to hold the State codes (01=AL, 02=AK, etc). Not sure or the best way to go about that for this purpose

2) Needs to check the left(editEvent.value, 2) of the County field to get the first two digits of the county value.

3) Check it against the array (??) to make sure it matches the value in the State field for the selected record.
Not sure how to do this or get the value of a different field for a selected record.
If not, editEvent.cancel = true;

I know how to do some simple validation on just the value being edited (as below) but this goes a couple of steps beyond that, and I could use a hand. thx...

addValidator = function(){
locgrid = ColdFusion.Grid.getGridObject('locGrid');

//this checks the DateComment field to make sure the user kept the input to under 100 characters. Just an example of validation
if (editEvent.field == "DATECOMMENT"){
var str = editEvent.value;
if ((str.length) > 100){
alert("There is a max of 100 characters for the DATE COMMENT field.");
editEvent.cancel = true;

29 Apr 2010, 7:18 AM
sorry.. a little desperate for any help at all on this. thx.