Welcome Guest Search | Active Topics | Sign In | Register

Grid Cell Value and Cell Text Options
Menon
Posted: Wednesday, August 5, 2009 5:50:57 AM
Rank: Advanced Member
Groups: Member

Joined: 8/9/2007
Posts: 59
Hi There,

I was wondering, if anybody here has come up with a problem like mine.
I use a simple grid with field
Name , Age , Country, which is dropdownlist eg: Country, which is a parameter.

I have the table Country from where i display all the countries.
Now on saving the record, i take the value from item.Cell[3].Value which displays
the country name, but i dont want to store the Country name, but its ID.

Currently i again call a sql method GetCountryID(Name);
which gets me the CountryID and i store it, ofcourse i think its not correct and the best way of coding.
Recently i faced a problem. My Parameter was "United Kingdom" two SPACES between two words
.But from the dropdownlist, the cell value was "United Kingdom" with one SPACE between two words.
So my sql method failed to get the ID.

Anyways, finally i believe i am doing it wrong, and i should have the ID strictly and not Name of Country.

The original solution for this would be the Cell have two Values one is Cell Text that is displayed and Cell Value that stores a value which is not displayed.

Its just a thought or suggestion.

I am sure this is a typical case which everybody must be using in their applications.
Do post your thoughts about it.

Thanks
Menon
eo_support
Posted: Wednesday, August 5, 2009 8:52:53 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,201
Hi,

The Grid has a KeyField that you can use. You can also use hidden columns.

Thanks
Menon
Posted: Friday, August 14, 2009 3:31:20 AM
Rank: Advanced Member
Groups: Member

Joined: 8/9/2007
Posts: 59
hi There,

Thanks again for your reply, and i am sorry for delaying this reply as i was out of station.

1. If i am not wrong, the Grid can only hold one value as KeyField?
Which i would probably use for the priimarykey of Table itself.

2. Using hidden columns, that sounds great.
But Again on changing the value of the dropdownlist, is it possible to change the value of this hidden column at Javascript funciton begin_edit & end_edit of dropdownlist?


Thanks

Menon
Menon
Posted: Sunday, August 16, 2009 8:23:56 AM
Rank: Advanced Member
Groups: Member

Joined: 8/9/2007
Posts: 59
Hi There,

i had tired the
[JavaScript]
GridCell.setValue(newValue)
in past, but i had probably made some syntax error due to which i was not able to make it work.

Finally today i managed to setValue of any Cell.

//On dropdownlist Javascript method end_edit we get object cell
var GridItem = cell.getItem();
//Column 5 can be your hidden column to save the CountryID
var GridCell = GridItem.getCell(5);
//Set your new value that can be the
var newValue = dropDownBox.options[selectedIndex].value;
GridCell.setValue(newValue);

This is great, so now from client side i can change value of other columns also.

I hope this helps other Users also.

Cheers
Menon


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.