Skip to Content
author's profile photo Former Member
Former Member

Model and binding issue

hello,

I have two views , a main view with a textbox and a button and a view that i want to use as a quick view that will show a pie chart for the textbox in the first view... , I used a global model as a model for the PIE and im changing the model data from the first view when user clicks the button..

pictures of the results:

and after I hover with the mouse on the textbox:

the code of the main view:


 
 
createContent : function(oController) { var oModel = new sap.ui.model.json.JSONModel({array:[ {status:"occ",seats:50}, {status:"free",seats:50} ]}); sap.ui.getCore().setModel(oModel, "model"); var pieView = sap.ui.view({viewName:"pietest.pie", type:sap.ui.core.mvc.ViewType.JS}); var rfl = new sap.ui.layout.ResponsiveFlowLayout(); rfl.addContent(pieView); var oQuickView = new sap.ui.ux3.QuickView( "QuickView1", { width:"auto", type:"Account", firstTitle: "fxhf", content:rfl, showActionBar:false }) var oInput1 = new sap.ui.commons.TextField("blat"); oInput1.setTooltip(oQuickView); var matrix = new sap.ui.commons.layout.MatrixLayout(); matrix.createRow(oInput1); matrix.createRow(new sap.ui.commons.Button({text:"press",press:function(){ var omod = sap.ui.getCore().getModel("model"); omod.oData.array[1].seats = 3; omod.refresh(); }})); return matrix; }

the code of the Pie view:

createContent : function(oController) {

  var omod = sap.ui.getCore().getModel("model");


    // A Dataset defines how the model data is mapped to the chart
  var oDataset = new sap.viz.ui5.data.FlattenedDataset({


  // a Bar Chart requires exactly one dimension (x-axis)
  dimensions : [
  {
  axis : 1, // must be one for the x-axis, 2 for y-axis
  name : 'status',
  value : "{status}"
  }
  ],


  // it can show multiple measures, each results in a new set of bars in a new color
  measures : [
     // measure 1
  {
  name : 'seats', // 'name' is used as label in the Legend
  value : '{seats}' // 'value' defines the binding for the displayed value
  },
  ],

  // 'data' is used to bind the whole data collection that is to be displayed in the chart
  data : {
  path : "/array"
  }

  });


     // create a Pie
  var oPie;


  oPie = new sap.viz.ui5.Pie({
  width : "400px",
  height : "480px",
  title : {
  visible : true,
  text : 'LOL'
  },
  dataset : oDataset
  });

  oPie.setModel(omod);



  return oPie;



  }



it doesn't refresh the data of the pie... after I click the button the pie stays 50:50 as it was before I clicked. any help please??

111111.JPG (3.1 kB)
22222.JPG (10.8 kB)
Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Posted on Jan 12, 2014 at 10:41 PM

    Hi!

    Try to use the setter setModel on pie chart to refresh it again after button click.

    Kind regards

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 13, 2014 at 01:52 AM

    May be to the refresh method you can pass 'true' to force refresh.

    Why dont you do a read again?

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.