Skip to Content

Hi all,

Recently I had an requirement, wherein, I had to bind the data from my function imports in odata services to my controls in XML view.

However, most of the solutions i found had achieved the same by doing a “oModel.callFunction()” in their controllers.

I was able to find a solution and thought I would share it in a blog post here.

Here is the sample code


<MultiComboBox items="{ path:'/myFunctionImport', parameters: { custom: { 'param1': '\'value1\'' } } }">
  <core:Item key="{Id}" text="{Text}"/>
</MultiComboBox>

Thanks,

Krishna

To report this post you need to login first.

2 Comments

You must be Logged on to comment or reply to a post.

  1. Kalthoum FERJENI

    Hello Krishna,

    Thank you to sharing the information, could you please give more details? how you can set values of your parameters from controller to XML?

     

    Many Thanks,

    Kalthoum.

    (0) 
  2. Laszlo Miko

    Hello Krishna,

     

    I would like to ask you that if it possibile to use a binded field instead of theĀ \value1\‘.

    Let me explain this via my example:

     

    in my detail.controller I use bindElement to bind an object to the dialog:

    onShowParticipants: function(oEvent) {
    			var sDialogFragmentName = "smartgym.view.fragment.ShowTrainingParticipantsDialog";
    			var oView = this.getView();
    			// create dialog lazily
    			if (!this._oShowTrainingParticipantsDialog) {
    				// create dialog via fragment factory
    				this._oShowTrainingParticipantsDialog = sap.ui.xmlfragment(sDialogFragmentName, this);
    				// connect dialog to view (models, lifecycle)
    				oView.addDependent(this._oShowTrainingParticipantsDialog);
    			}
    
    			this._oShowTrainingParticipantsDialog.bindElement(oEvent.getSource().getBindingContext().getPath());
    			this._oShowTrainingParticipantsDialog.open();
    
    		},

    in the dialog fragment I want to call a function import using the {TrainingId} paramater which is one property of the binded Object (above in the detail.controller):

    			<List
    				items="{ path: '/GetUsersofTraining', parameters: { custom: { 'TrainingId': '\'{TrainingId}\'' } }, sorter: { path: 'UserId', descending: false } }"
    				headerText="Participants">
    				<StandardListItem title="{ path: 'UserName'}" />
    			</List>

     

    In tihs case the GET request looks like this:

    GetUsersofTraining?$skip=0&$top=100&$orderby=UserId asc&TrainingId='{TrainingId}’

    and I don’t get any data.

     

    Do you have any advice, how can I do this in a right way?

     

    Many thanks,

    Laszlo

    (0) 

Leave a Reply