0
votes

I've a sapui5 application which has several controls in my page. Such as Tables , Calendar etc.

And I've create a singe model for my page in the onInit event as follows

var viewModel = new JSONModel();

            //Prepare Initial Model
            viewModel.setData({
                LineDetails: [],
                Calendar: {},
                PageMode: "add",
                DateStart: new Date(),
                DateEnd: new Date(),
                IsHistoryAvailable: false
            });
           this.getView().setModel(viewModel);

What I need to do is, I've to include a Smart Table inside a dialog in this page. The dialog will open once I click a button in the page. How can I bind data to the smart table inside the dialog?

I only have experience of binding the model to a smart table which either declaring default model in the manifest or in the page.

But here I've already added a model to the page in the onInit event. So how can I bind data?

Is there a way to bind smart table to a Property which included in the above declared model.

Propert name : SmartTableModel

eg :

viewModel.setData({
                    SmartTableModel:[]
                    LineDetails: [],
                    Calendar: {},
                    PageMode: "add",
                    DateStart: new Date(),
                    DateEnd: new Date(),
                    IsHistoryAvailable: false
                });
1
If you add your dialog to your view by calling addDependent it has access to all the models of the view.Marc
yes, but how can I add a separate model for smart tabletarzanbappa
create a second model, give it a different name.Marc
But, I think smart table cannot bind to a model with different name.. I've to add the midel to page like this.getView().setModel(oModel2); cannot figure out a waytarzanbappa

1 Answers

0
votes

Per default, the data you want to bind must come from an ODataModel which is the default model! In other words: you can't simply bind data from some JSONModel, and you can't bind data to a SmartTable which comes from a named model (even if it's and ODataModel).

  1. SmartTable only works with data from an ODataModel, thus you can't work with JSonModels
  2. Currently, SmartTable only works with dafault models (""), i.e. named model won't work

I'm afraid to tell you that what you want does not work as of today. You could use the MockerServer + annotations in your real app code (not onbly for testing) as a workaround, but I think I would avoid that. There are some other tricks as well, you could start reading here: SAP UI5 :named json model with smart table