Adding more fields to form than in grid (Contact Manager)


#1

Hi,

So I followed the Contact Manager tutorial.

I’d like to extend it a little bit.

Let’s say on the left hand side, there’s the list of contacts, using the grid, of Last Name and First Name columns.

On the right hand side, when the user selects a particular row of the grid, it selects that contact.

Currently the tutorial has the form displaying the same fields as what is shown on the grid.

However, what if I want additional fields in the form, like Gender, notes, phone number, that I don’t need to be included in the grid, but should be on the form, because those are Contact Details. How do I get this to work? Do I need to include those fields in the grid so that the connector can query for them? I tried not including the fields in the grid, but the form wouldn’t pick up on the values. Would I need to use the Form Connector somehow and bind it to the grid? Can I bind two connectors to the grid?

Thx.


#2

When a set of fields differ a lot between two components, it will be better to use separate server side data feeds ( separate connectors )
On selection a row in a grid, you can call something like

form.load("form_data.php?id="+id)

Where ID is ID of the updated row
If a set of fields is very similar you can use a solution with DataStore

[code]var ds = new dhtmlXDataStore();
ds.load(“full_data.php”);

grid.sync(ds);
form.bind(ds);
[/code]

and on selection of a row, the code can call

ds.setCursor(id);

where id - id of selected row, as result the form and the grid will use the same data, and form edit operations will be reflected in the grid automatically.