Giter Club home page Giter Club logo

basic_crud_community's People

Contributors

uxkjaer avatar

Stargazers

 avatar

basic_crud_community's Issues

oList values not passing to SetBoundMasterList in ListSelector.js

Hello uxkjaer,

I tried the same clean code approach for my CRUD UI5 application but the Promise is not getting fulfilled as your code does.
Below is the code I have written in my app. Could you please have a look and let me know what I'm missing.

_**Master.controller.js
sap.ui.define([
'sap/master/detail/controller/BaseController',
'sap/ui/Device'
], function (Controller, Device) {
"use strict";

	return Controller.extend("sap.master.detail.controller.Master", {
		
		onInit: function() {
			var oList = this.byId("list");
			this._oList = oList;
			this._oListSelector = this.getOwnerComponent().oListSelector;
			
			oList.attachEventOnce("UpdateFinished", function(){
					
			});
			
			this.getView().addEventDelegate({
				onBeforeFirstShow: function(){
					this._oListSelector.setBoundMasterList(oList);
				}.bind(this)
			});
			
			// this._oListSelector.setBoundMasterList(oList);
			this.getRouter().getRoute("master").attachPatternMatched(this._onMasterMatched, this);
		},
		
		_onMasterMatched: function(){
			this._oListSelector.oWhenListLoadingIsDone.then({
				function(mParams){
					if(mParams.list.getMode === "NONE"){
						return;
					}
					var sObjectPath = mParams.firstListItem.getBindingContext().getProperty("Pernr");     
				}	
			});	
		},**_

_**ListSelector.js
sap.ui.define(['sap/ui/base/Object'],
function (BaseObject) {

return BaseObject.extend("sap.master.detail.controller.ListSelector", {
	
	constructor: function(){
		this._oWhenListHasBeenSet = new Promise(function(fnResolveListHasBeenSet){
			this._fnResolveListHasBeenSet = fnResolveListHasBeenSet;	
		}.bind(this));
		
		this.oWhenListLoadingIsDone = new Promise(function(fnResolve, fnReject){
			this._oWhenListHasBeenSet
				.then(function(oList) {
					 oList.getBinding("items").attachEventOnce("dataRecieved", {
						function(oData){
							if(!oData.getParameter("data")){
								fnReject({
									list: oList,
									error: true
								});
							}
						var oFirstListItem = oList.getItems()[0];
						if(oFirstListItem){
							fnResolve({
								list: oList,
								firstListItem: oFirstListItem
							});
						}else{
							fnReject({
								list: oList,
								error: false
							});
						}
						
						}	
					 });
				});
		}.bind(this));
	},
	
	setBoundMasterList: function(oList){
		this._oList = oList;
		this._fnResolveListHasBeenSet(oList);
	},
	
	clearMasterListSelection: function(){
		this._oWhenListHasBeenSet.then(function(){
			this._oList.removeSelections(true);	
		}.bind(this));
	},**_

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.