Blama
Thanks a lot!!!
Now it works perfectly!
Announcement
Collapse
No announcement yet.
X
-
Let me put it this way then:
What I'm trying to do is to use a DynamicForm to insert values into a DataSource (SQL table in my case). How can I do that by using SmartClient JavaScript?
All examples I've seen so far just covers how to update an existing value, but not inserting a new one.
Leave a comment:
-
So, again, your code is simply crashing because you are trying to access something that isn't documented and doesn't exist. Stop doing that and let us know if you have troubles at that point.
Leave a comment:
-
So what shall I write instead? When I call theForm.saveData() it always fails if ID is empty, and it will always be empty when adding a new record.
Leave a comment:
-
There is no such thing as isc.DSOperationType so your code is simply crashing trying to access null. You appear to have just guessed that such a class might exist, but it does not - use the docs.
Leave a comment:
-
DynamicForm, update existing record or creating a new one
I'm trying to use a DynamicForm for both adding and updating records in a SQL DataSource, but I'm having problem with telling it if shall update or save.
If the field marked with primaryKey="true" is filled then it shall make an update and if it is empty then it shall make an add operation.
The DataSource is defined by the XML:
<DataSource ID="Contact" serverType="sql" tableName="contact">
<fields>
<field name="id" type="sequence" title="ID" hidden="false" primaryKey="true"/>
<field name="firstName" type="String" required="false" title="First Name" escapeHTML="true"/>
<field name="lastName" type="String" required="false" title="Last Name" escapeHTML="true"/>
</fields>
</DataSource>
and the JavaScript looks like this:
<isomorphic:loadDS ID="Contact" />
isc.DynamicForm.create({
ID:"ContactForm",
autoDraw:false,
autoFetchData:true,
dataSource: Contact,
wrapItemTitles:false,
height:"auto",
width:"auto" })
isc.Button.create({
ID:"ContactFormNewButton",
title:"New",
click:"ContactForm.editNewRecord()" })
function saveOrUpdate() {
if (ContactForm.getField("id").getValue()==null) {
ContactForm.setSaveOperationType(isc.DSOperationType.ADD);
} else {
ContactForm.setSaveOperationType(isc.DSOperationType.UPDATE);
}
ContactForm.saveData();
}
isc.Button.create({
ID:"ContactFormSaveButton",
title:"Save",
click:"saveOrUpdate()"
})
But when pressing the "Save" button the console says:
Uncaught TypeError: Cannot read property 'UPDATE' of undefined
at saveOrUpdate ((index):78)
at _3.eval [as click] (eval at isc__makeFunction (ISC_Core.js?isc_version=v11.1p_2017-11-02.js:77), <anonymous>:3:8)
at _3.isc_StatefulCanvas_handleActivate [as handleActivate] (ISC_Foundation.js?isc_version=v11.1p_2017-11-02.js:233)
at _3.isc_StatefulCanvas_handleClick [as handleClick] (ISC_Foundation.js?isc_version=v11.1p_2017-11-02.js:234)
at _3.isc_c_EventHandler_bubbleEvent [as bubbleEvent] (ISC_Core.js?isc_version=v11.1p_2017-11-02.js:2042)
at _3.isc_c_EventHandler_handleClick [as handleClick] (ISC_Core.js?isc_version=v11.1p_2017-11-02.js:1898)
at _3.isc_c_EventHandler__handleMouseUp [as $k5] (ISC_Core.js?isc_version=v11.1p_2017-11-02.js:1883)
at _3.isc_c_EventHandler_handleMouseUp [as handleMouseUp] (ISC_Core.js?isc_version=v11.1p_2017-11-02.js:1874)
at _3.isc_c_EventHandler_dispatch [as dispatch] (ISC_Core.js?isc_version=v11.1p_2017-11-02.js:2128)
at HTMLDocument.eval (eval at isc__makeFunction (ISC_Core.js?isc_version=v11.1p_2017-11-02.js:77), <anonymous>:3:123)
Any idea what's wrong?
Browser = Chrome, Version 63.0.3239.132 (Officiell version) (64 bitar)
SmartClient Version: v11.1p_2017-11-02/Pro Development Only (built 2017-11-02)Last edited by abc80; 5 Feb 2018, 03:29.Tags: None
Leave a comment: