dynamicForm with customized fields.

Is it necessary to call create() whenever setDataSource is called?

In the following codes, it causes ‘this.form has no properties’ error when the function gets called the 2nd time. (singleEditor is a dynamic form).

But if it is changed to 'setDataSource(ds), it works fine.

Thanks!

        setDataSource: function (ds) {
	        this.singleEditor.setDataSource(ds,this.formFields);
//	        this.singleEditor.setDataSource(ds);
        }

Hi xwang,

This may be a problem with reusing form fields across editors.

Try:

    this.singleEditor.setDataSource(ds, isc.clone(this.formFields));

If this fixes it, it would be great if you could show the rest of the code. There may be a bug we want to correct.

It does fix the problem. Thanks!

But the codes are proprietary. I have a tight schedule right now, hardly got time to make another sample.

Here is the structure:

object A creates two members :list B (not standard), dynamic form C. A is passed to B as ‘creator’. The DS is created in B, and set it back to A by calling this.creator.setDS as you see in the codes. The formFields are defined in A.

Hi xwang,

OK, no bug in SmartClient then. You’ve hit a subtle issue with custom classes: if you define an Array or Object property on a class, all instances of the class share that Array or Object. For safety reasons, Array or Object defaults should usually be dynamically created in initWidget().

I notice that

 this.singleEditor.setDataSource(ds, isc.clone(this.formFields));

the above code sends two queries to database, which is WSDL binding. It gets the same results.

vs

 this.singleEditor.setDataSource(ds);

doesn’t send any queries.

All other codes are exactly the same. Is there a way to avoid redundant traffic?

thanks!

setDataSource() doesn’t directly cause fetches. Where are these fetches coming from, optionDataSource settings on those fields?

there is no optionDataSource in any fields. Just comment out setDataSource, the query disappears; adding back, the querying back.

It appears to me that when creating dynamicForm from the defined fields causes query traffic.

Sorry, but that call on it’s own simply does not lead to fetches. Something you are doing later, which may include drawing the form with autoFetchData:true or optionDataSource settings, causes the fetch.

It’s not possible for anyone to point out what’s going on until you show complete code.

If the datasource is set into two objects which are parts of a compound object, will there be two queries when the compound object is open.

This depends on what the objects are, how they are configured and what methods you are calling on them. Sorry, there’s no substitute for showing example code.