Skip to Content
0

I want to create custom control but i am not getting data from controller

Feb 24, 2017 at 05:53 AM

24

avatar image
//Custom Control Code


sap.ui.core.Element.extend("Final_CC.control.PracItem", { metadata : {
	properties : {
		"region" : {type : "string", group : "Misc", defaultValue : null}
		}
}});	
sap.ui.core.Control.extend("Final_CC.control.Prac", {
	metadata : {
	
		aggregations : {
			"items" : { type: "Final_CC.control.PracItem", multiple : true, singularName : "item"}
		}
		,
		defaultAggregation : "items",
		events: {
			"onPress" : {},
			"onChange":{}		
		}			
	},



onAfterRendering: function(){
var oBindingInfo = this.getBindingInfo('items');
    var oModel = oBindingInfo.binding.getModel();
    var sPath = oBindingInfo.path;
    var data = oModel.getProperty(sPath);
    


    for (var i = 0; i < data.length; i++) {
      if (data[i][key] === t.getKey()) {
        data.splice(i, 1);
        this.removeAggregation('items', i, true);
        break;
      }
    }

}





//Controller Code

	return Controller.extend("Final_CC.controller.View1", {
		onInit: function() {
			
			var gModel = new sap.ui.model.json.JSONModel("model/Products.json");
			sap.ui.getCore().setModel(gModel,"pro");
		this._rebindAll();
	},


	_rebindAll : function() {
	var oModel = sap.ui.getCore().getModel("pro");
var oComparisonHolder = this.byId("QperformanceToTargetComparisonHolder");
var oComparisonItem = new Final_CC.control.PracItem({region:"{ProductName}" );
var oComparison = new Final_CC.control.Prac({
			items: {path : '/Products', template : oComparisonItem}
		});

	oComparison.setModel(oModel);
		oComparisonHolder.addItem(oComparison);


}
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

0 Answers