Parameter to appserver - Forum - Mobile - Progress Community

Parameter to appserver

 Forum

Parameter to appserver

This question is answered

Hi There,

I have created a data list view in telerik mobile.
I have linked the fields from the business entity to the list view.

On show its doing a read to the appserver but how do i manipulate this read to pass in a parameter so i can use this to get my records from the appserver side?

EG: i have a debtors enquiry. on show of that page i want to send down a account number to the appserver so i can bring back debtor/s for that account number.

How would i do this?

Thanks in advance,

Meyrick

Verified Answer
  • Hello Meyrick,

    You can use the CUSTOM CODE section at the bottom of index.js to change the properties of the DataSource before it is created by the onShow event. See example below.

    The serverFiltering property is also set to true by configuring the Filtering section under Configuration.

    I hope this helps.

    Example:

    // START_CUSTOM_CODE_homeModel
    var dataSourceOptions = app.home.homeModel.get("_dataSourceOptions");
    //alert("DEBUG: " + JSON.stringify(dataSourceOptions));
    dataSourceOptions.serverFiltering = true;
    dataSourceOptions.serverPaging = true;
    //dataSourceOptions.serverSorting = true;
    dataSourceOptions.transport = {
        countFnName: "count"
    };
    dataSourceOptions.filter = {
        field: "Name",
        operator: "contains",
        value: "Athlete"
    };
    // END_CUSTOM_CODE_homeModel
    

All Replies
  • Hello Meyrick,

    The simplest way to do this is to use the JSON Filter Pattern (JFP).

    You add support for the pattern in the Business Entity and then you can enable serverFiltering in the Kendo UI DataSource and pass a filter to the backend using the either filter configuration property of the DataSource or programmatically, by calling the filter() method in the DataSource.

    Here is an example using the JSON Filter Pattern with a Kendo UI Grid:

       oemobiledemo.progress.com/.../example014b.html

    Here is a link to the documentation explaining how to add code to implement the pattern:

       documentation.progress.com/.../

    An alternative to this approach is to use the filter property in the Kendo UI DataSource with the JSON Filter Pattern.

    In this case, the Business Entity would receive a filter with JSON object that you would have parse.

    With this approach, it is easier to validate the parameters on the server, however, you have to implement the code to parse t he JSON object.

    Another alternative would be to implement your method to pass parameters, however, there is no official support for this approach.

    You can read on this approach in the following thread if you are interested:

    community.progress.com/.../69540

    I hope this helps.

  • Hi Edsel,

    Thank you for this information.

    I am now able to set the filter using the example supplied in the Kendo UI Grid example.

    I have done so by adding the filter parameters to the automated code that Telerik supplies once the view has been created. If i now go and edit a view that code will be removed.

    How would it be possible to add the code the the custom code section?

    Below is a snippet from the automated code, I need to be able to reference the serverFiltering and filter parameters in the custom code section.

    (function(parent) {

       var dataProvider = app.data.progressDataProviderAnonymous,

           jsdoOptions = {

               name: 'beDrsmas',

               autoFill: false            

           },

           dataSourceOptions = {

               serverFiltering: true,

           filter: {value: returnUserField('useraccno')},          

               type: 'jsdo',

               transport: {},

               error: function(e) {

                   if (e.xhr) {

                       alert(JSON.stringify(e.xhr));

                   }

               },

               schema: {

                   model: {

                       fields: {

                           'dmname': {

                               field: 'dmname',

                               defaultValue: ''

                           },

                       }

                   }

               },

           },

    Do you know how this would be possible?

    Thanks in advance,

    Meyrick

  • Hello Meyrick,

    You can use the CUSTOM CODE section at the bottom of index.js to change the properties of the DataSource before it is created by the onShow event. See example below.

    The serverFiltering property is also set to true by configuring the Filtering section under Configuration.

    I hope this helps.

    Example:

    // START_CUSTOM_CODE_homeModel
    var dataSourceOptions = app.home.homeModel.get("_dataSourceOptions");
    //alert("DEBUG: " + JSON.stringify(dataSourceOptions));
    dataSourceOptions.serverFiltering = true;
    dataSourceOptions.serverPaging = true;
    //dataSourceOptions.serverSorting = true;
    dataSourceOptions.transport = {
        countFnName: "count"
    };
    dataSourceOptions.filter = {
        field: "Name",
        operator: "contains",
        value: "Athlete"
    };
    // END_CUSTOM_CODE_homeModel
    

  • Thank you very much Edsel!