How to connect to a business entity using custom HTML elemen

Posted by tinkerfixergeek on 13-Oct-2017 10:11

Hello,

I'm having some trouble understanding how to go about connecting to a remote data source that would be a business entity created in PDSOE via my JavaScript code.

For example purposes, I am using the Sports database.  I have created a business entity in DevStudio from the Employee table.  I exposed the service to my local PASOE instance and have no issues seeing the service or the data via a browser.  Opening KUIB, I created a basic test app and can see the data using a basic grid view without issue as well.

The problem I am having is beyond this basic usage.  I have created a blank view with a couple of custom HTML elements that I can work with in the Controller.Public.js file and I am trying to figure out how to properly write the calls to talk to my business entities.  

For example, trying to get just a basic KendoDropDownList to work:

$("#employees").kendoDropDownList({
    dataTextField: "FirstName",
    dataValueField: "EmpNum",
    dataSource: {
        transport: {
            read: {
                dataType: "json",
                url: "localhost:8810/.../beEmployee",
            }
        }
    }
});

Using a business entity that contains data that looks like:

"dsEmployee": {
    "prods:hasChanges": true,
    "ttEmployee": [
        {
            "EmpNum": 1,
            "LastName": "Koberlein",
            "FirstName": "Kelly"
        }
    ],
    "prods:before": {}
}

I think my issue is in a misunderstanding of what the type of data is, but there are not many examples currently of connecting to this kind of entity (JSDO?).  The current Kendo examples all seem to be using JSONP or ODATA types.

I can get custom elements to work with locally created data sources and have seen some examples that looked like they were converting the incoming data into a local source.  Is that what should be done, and how would I do that if so?

I've also seen examples where a schema and model are used but am unsure of how that would look either.

James

All Replies

Posted by egarcia on 13-Oct-2017 12:31

Hello James,

In general, you do not need to write your own code to define the Data Sources.

When using a blank view, you would set the View's Data Sources in the View Properties to specify the DataSources.

The usage would be automatic by the view (code is generated into controller.js).

If you want to customize the code you can create your own DataSource definitions in controller.public.js.

The code to use the JSDO would look like the following:

$("#employees").kendoDropDownList({
    dataTextField: "FirstName",
    dataValueField: "EmpNum",
    dataSource: {
        type: "jsdo",
        transport: {
                jsdo: "beEmployee"
        }
    }
});

Here are some links to some examples:

http://oemobiledemo.progress.com/

http://oemobiledemo.progress.com/jsdo/example014.html

https://github.com/CloudDataObject/kendo-ui-builder-samples

Check both the master and develop branches. There are some samples available that have not been promoted yet to the master branch.

Please let me know if you need additional information.

I hope this helps,

Edsel

This thread is closed