cancel
Showing results for 
Search instead for 
Did you mean: 

set a control's model

Former Member
0 Kudos

Hello,

What I want to do is firstly create a entry, then set the entry as my view's model

my code is like

oDataModel.create('/entries', entry, {

        success : function(oData) {

             var oVizFrame = self.getView().byId("idoVizFrame");

             oVizFrame.setModel(new JSONModel("/enties('"+oData.Id+"')"));

       }

});

The oDataModel contain the service root path so I pass only '/entries/'

however, in this line

oVizFrame.setModel(new JSONModel("/enties(guid'"+oData.Id+"')"));


how can I get my root path?


Besides, is there a better way to do it?


Thanks a lot

Accepted Solutions (1)

Accepted Solutions (1)

SergioG_TX
Active Contributor
0 Kudos

Hi Yan, the better way would be to set the model at the view level that way you can get the model for different controls based on the path - the root path will contain all the different types of data for your view. hope this helps.

Answers (3)

Answers (3)

Former Member
0 Kudos

Finally what I do is :

oDataSet = oVizFrame.getDataset();

// bind url = ".../Points";

oDataset.bindData(bindUrl);

former_member182372
Active Contributor
0 Kudos

What is the point of doing

("/enties(guid'"+oData.Id+"')" ??


you expect json model to be like odatamodel? that will not work this way


what i would do:


oVizFrame.setModel(oDataModel);

oVizFrame.bindElement( "/enties(guid'"+oData.Id+"')" );

Former Member
0 Kudos

Thanks for your reply

This is exactly what I'm looking for. It still have some issues :

I want to do it like this:

I have my oDataModel which bind to  /OData.svc/

var oDataModel;

// I use this model to create an entity:

oDataModel.create('/entities', entity,{

     success: function(entry){

          oVizFrame.bindElement("/entities(guid'" +entry.Id + "')");

     }

})

the oVizFrame use the dataset :

var oDataset = new FlattenedDataset(

     {

          dimensions: [{ name: "Time", value: "{Time}", dataType : 'date' } ],

          measures: [ { name : "Value", value : "{Value}" } ],

          data: { path: "/Points"  }

     }

);    

however, to get my timeseries data,  sapui5 use the url

/Points

instead of

/Entities('id')/Points

Please help me if you know how to write it correctly

Thanks a lot.

Yan

former_member182372
Active Contributor
0 Kudos

replace



data: { path: "/Points"  }



with


data: { path: "Points"  }

agentry_src
Active Contributor
0 Kudos

The incomplete Discussion was deleted. 

Regards, Mike (Moderator)

SAP Technology RIG