This is a migrated thread and some comments may be shown as answers.

Creating a Form that uses progressDataProvider

5 Answers 81 Views
HTML5, CSS, JavaScript
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Tim
Top achievements
Rank 1
Tim asked on 11 Apr 2016, 02:49 PM

Hello! I'm afraid I need some help.

I'm trying to make a form that submits to a database. What we've done so far is to expose our OpenEdge data as REST and we used the Telerik Platform to get at the OpenEdge backend. Using the Views service, I added a Master Detail view that shows a list of entries in our chosen table, and shows the rest of the information in the Detail section of that view. This was easy enough to do in the Views service. I then also added a Form view, which is also my home view, that I want to use to send data to this table using the same connection. However, unlike the Master Detail view, I was not able to form this connection just from the Views service, so now I am in the code area attempting to do it manually. I am having some trouble figuring out how to do this, so my question is:

Is it possible to connect a Form view to the progressDataProvider dataSource manually in the custom code sections after creating it in the Views service?

Are there some examples of the code for this?

Any advice would be appreciated.

Thanks!

5 Answers, 1 is accepted

Sort by
0
Accepted
Kaloyan
Telerik team
answered on 14 Apr 2016, 02:46 PM
Hi Tim,

In order to connect the form to the Progress Data Service you have added, you will need to write some custom code in the index.js file of the form component. The code should use the already included Progress JSDO library and call its methods to create the data. If you are using a Form or Basic Authentication, you will also need to have an Authentication view in your app and make sure that you are logged in before you open the form to create data. Otherwise you will not have a valid session and no changes will be submitted. Here is some sample code you can add in the custom code section of the form's index.js file:

app.formView.formViewModel.submit = function() {
    var dataProvider = app.data.progressDataProvider;
 
    dataProvider.loadCatalogs().then(function _catalogsLoaded() {
        // this is the JSON object that will be sent
        // model example:  {"name": "Telecines","deptCode": "TC","description": "null"}
        var model = app.formView.formViewModel.fields.toJSON(),
               jsdoOptions = {
                name: '$ORG_DEPT', // this is the name of your table
                autoFill: false
            },
            jsdo = new progress.data.JSDO(jsdoOptions);
 
        // here is where the data is created
        jsdo.create(model);
        jsdo.saveChanges(false).done(function _saveCallback() {
            // .. handle result
        });;
    });
};

The above code assumes the name of your form is 'formView' and the name of your data provider is 'progressDataProvider'. You need to update all the names in the code to match what you have in your app

I hope this helps.

Regards,
Kaloyan
Telerik
 

Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

 
0
Tim
Top achievements
Rank 1
answered on 15 Apr 2016, 01:33 PM
Thank you! This is exactly the help I was looking for, I'll let you know if it works!
0
Tim
Top achievements
Rank 1
answered on 18 Apr 2016, 09:28 PM

Ok, we are SO CLOSE! It's writing to the database, but not in the correct way. Some of the values are gettign written to correctly, while others are receiving incorrect values, or none at all. Is this a known issues? I have a feeling that this problem is related to using just the toJSON method, and this is not giving OpenEdge enough information, or incorrect information. Is there a way to integrate this with the DataSource and more explicitly assign the form values to the the table fields? I'm looking to create something like this:

    dataSource.add({
                    COMMENTS: addFormData.createComments,
                    WRAPPED: addFormData.createWrapped,
                    STOP_SEQ: addFormData.createStopSeq,
                    EACHES_BOXES: addFormData.createEachesBoxes,
                    MEAT_CHEM: addFormData.createMeatChem,
                    CRUSHABLE: addFormData.createCrushable,
                    LIQUIDS_UPRIGHT: addFormData.createLiquidsUpright,
                    BUILT_WELL: addFormData.createBuiltWell,
                    MISPICKS: addFormData.createMispicks,
                    ROUTE: addFormData.createRoute,
                    PALLET_NUM: addFormData.createPalletNum,
                    PALLET_ID: addFormData.createPallet,
                });

Can the progressDataProvider be made into a usable DataSource?

0
Lini
Telerik team
answered on 21 Apr 2016, 11:12 AM
Hello,

The code from Kaloyan's message does not use a Kendo DataSource - it adds the data directly using the JSDO library methods. If you want to modify the model before sending it to OpenEdge, you can just update the JavaScript object and add the needed properties or modify the type of existing ones. You can also create your own custom model and don't rely on the default one (that goes .toJSON() ). The Kendo DataSource component integration with JSDO is used only in the Master/Detail view type.

Regards,
Lini
Telerik
 

Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

 
0
Tim
Top achievements
Rank 1
answered on 22 Apr 2016, 01:51 PM
Ok, thank you for clearing that up! There is so much to learn, thanks for all the help.
Tags
HTML5, CSS, JavaScript
Asked by
Tim
Top achievements
Rank 1
Answers by
Kaloyan
Telerik team
Tim
Top achievements
Rank 1
Lini
Telerik team
Share this question
or