Creating a Form that uses progressDataProvider

6 posts, 1 answers
  1. Tim
    Tim avatar
    8 posts
    Member since:
    Nov 2014

    Posted 11 Apr Link to this post

    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!

  2. Answer
    Kaloyan
    Admin
    Kaloyan avatar
    872 posts

    Posted 14 Apr Link to this post

    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.

     
  3. Tim
    Tim avatar
    8 posts
    Member since:
    Nov 2014

    Posted 15 Apr in reply to Kaloyan Link to this post

    Thank you! This is exactly the help I was looking for, I'll let you know if it works!
  4. Tim
    Tim avatar
    8 posts
    Member since:
    Nov 2014

    Posted 18 Apr Link to this post

    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?

  5. Lini
    Admin
    Lini avatar
    2144 posts

    Posted 21 Apr Link to this post

    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.

     
  6. Tim
    Tim avatar
    8 posts
    Member since:
    Nov 2014

    Posted 22 Apr in reply to Lini Link to this post

    Ok, thank you for clearing that up! There is so much to learn, thanks for all the help.
Back to Top