New Posts New Posts RSS Feed: Change cells from text to comboboxes depeding on other data
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Change cells from text to comboboxes depeding on other data

 Post Reply Post Reply
Author
DataMan View Drop Down
Groupie
Groupie
Avatar

Joined: 26-Jul-2007
Location: Canada
Posts: 52
Post Options Post Options   Quote DataMan Quote  Post ReplyReply Direct Link To This Post Topic: Change cells from text to comboboxes depeding on other data
    Posted: 10-Aug-2007 at 1:29pm
Just looked and this post should be in a different forum,  sorry.
 
I want to know the best way to handle my situation with dev force,  new to databinding and a green horn to object orientated programming.
 
Preamble before the question:
 
I have a table called SysCodes that has columns:
SysCodeID
SysCodeParentID
SysCodeDescription
 
And the data in this table looks like the following
 
1, 0, ApplyTo
2, 0, DataType
3, 0, Color
4,1,In Place
5,1,In Process
6,2,System Code List
7,2,Boolean
8,2,Number
9,3,Red
10,3, Yellow
 
I created 2 classes in the object mapper called SC_ApplyTo, SC_DataType but the third one Color is not an enumeration because the user is allowed to add as many colors as they want into the System code table.  They are not allowed to edit or add to datatypes or apply to.
 
I unchecked the visible box for the ones I don't want in that particular enumeration.
 
When creating the classes I put in a where clause to filter the data.  for example SysCodeParentID=1 for the SC_ApplyTo Class.
 
Question Setup:
On a form there is a datagrid with 3 columns bound to a table called Results:
 
DataType, SyscodeType, Value
 
If the user chooses a data type of Value then Syscodetype column is disabled and the user simply types in a number.
If the user chooses boolean then the value field becomes a combobox where they can choose True or False which is translated back to the DB as 0 or 1.
 
If the user chooses a data type of System Code List then the syscodetype column is enabled and the user is able to choose from a list of SyscodeTypes (Applyto, Datatype or Color).  When they choose from that list the value column then becomes a combobox with a list of colors in it that the user can choose. (assuming they picked the syscodetype of color)
 
Ok, here's the question:
 
I'm new to this whole databinding and DevForce thing and even object oriented programming and I want to know the best way to do this. 
 
One way is to create a new property called ShownValue in the Result table class. 
 
public String ShownValue
{

get {
return the text or number converted to string depending if the Datatype is syscodelist,boolean or value.
 }

set {

if the value is lets say Red then set the value field in the table to the related syscodeid that matches to Red.
 }

}

I don't like this way because I have to cast the number to a string and if the value they entered in was 1.2345 it's a string.
 
I've got this working perfectly in the current application because we are not using databinding and I use the events of the grid to change the cells to comboboxes and fill them with the correct values.  We are using infragistics controls and I use the RowInitialize and the cell changed events to handle all the logic.
 
What's the best way todo this with databinding and devforce?  There are 2 places that need to work together, the Results object and the grid.


Edited by DataMan - 10-Aug-2007 at 1:34pm
Back to Top
pkarsh View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 14-Jun-2007
Location: United States
Posts: 32
Post Options Post Options   Quote pkarsh Quote  Post ReplyReply Direct Link To This Post Posted: 20-Aug-2007 at 1:02pm
There are a number of items in the DevForce documentation set that you can look at to get started learning databinding.

Chapter 7 of the Developer's Guide has a topic called "DevForce Binding Architecture".

There are a number of tutorials to help you learn about databinding. These include:

Intermediate level:
204 - Data Converters and View Descriptors
210 - Composing Forms with User Controls
264 - Working with Combo boxes

Advanced:
334 - User-defined columns
374 - Binding to non-Persistable objects

The numbers given are those for these Tutorials in the current release (3.5.3.1). They may be different for other releases

In particular the Tutorial on Binding to non-Persistable objects may help you with combo box for selecting boolean values that you mentioned.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down