on 10-23-2015 9:14 AM
Hi All,
While i navigate from detail1 page to another master2-detail2 page , i have to select first record in master2 by default while laoding master2-detail2.
but it is not working and no error in console also.
below is my code for default selection.
in master2 controller and in onInit() method i have written code as below.
this.waitForInitialListLoading(function() {
//On the empty hash select the first item
this.selectFirstItem();
});
waitForInitialListLoading: function(fnToExecute) {
jQuery.when(this.oInitialLoadFinishedDeferred).then(jQuery.proxy(fnToExecute, this));
},
selectFirstItem: function() {
var oList = this.getView().byId("list2");
var aItems = oList.getItems();
if (aItems.length) {
oList.setSelectedItem(aItems[0], true);
}
},
please help
Regards,
Vamsi
Hi Vamshi,
Check these Samples -
http://jsbin.com/zomocosofa/edit?html,js,output
http://jsbin.com/noxuzog/edit?js,output
Regards,
Sai Vellanki.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Try this
Hi Vamsi,
Were you able to get items here ?
var oList = this.getView().byId("list2");
var aItems = oList.getItems();
Put a breakpoint and check the variable aItems. If data is available then these methods should work
aItems[0].setSelected(true);
oList.setSelectedItem(items[0],true);
Regards,
Sai Vellanki.
Hi Sai,
my code is in master2 controller and
below is my code and console result :
onAfterRendering: function(evt) {
var x = 5;
//Wait for the list to be loaded once
this.waitForInitialListLoading(function() {
//On the empty hash select the first item
this.selectFirstItem();
});
},
waitForInitialListLoading: function(fnToExecute) {
jQuery.when(this.oInitialLoadFinishedDeferred).then(jQuery.proxy(fnToExecute, this));
},
selectFirstItem: function() {
var oList = this.getView().byId("list2");
var aItems = oList.getItems();
if (aItems.length) {
// oList.setSelectedItem(aItems[0], true);
aItems[0].setSelected(true);
}
},
Console result for aItems[0] :
aItems[0]
f {bAllowTextSelection: true, mEventRegistry: Object, sId: "__xmlview3--mainListItem2", mProperties: d, mAggregations: Object…}_active: false_oFavIcon: f_oFlagIcon: f_oPlaceholderIcon: f_oSingleSelectControl: f_oTitleText: f_sOwnerId: "__component0"_sapui_bInAfterRenderingPhase: trueaBeforeDelegates: Array[0]aDelegates: Array[0]bAllowTextSelection: truebOutput: truebSelectedDelayed: undefinediSuppressInvalidate: 0mAggregations: ObjectmAssociations: ObjectmBindingInfos: ObjectmBindingParameters: nullmBoundObjects: ObjectmElementBindingContexts: ObjectmEventRegistry: ObjectmMethods: ObjectmProperties: dmSkipPropagation: ObjectoBindingContexts: ObjectoModels: ObjectoParent: f_aNavSections: Array[2]0: "__xmlview3--list2-listUl"1: "__xmlview3--list2-trigger"length: 2__proto__: Array[0]_aSelectedPaths: Array[0]_bItemNavigationInvalidated: true_bReceivingData: false_bRendering: false_bSelectionMode: true_bUpdating: false_oGrowingDelegate: B.extend.constructor_oSelectedItem: f_active: false_oFavIcon: f_oFlagIcon: f_oPlaceholderIcon: f_oSingleSelectControl: f_oTitleText: f_sOwnerId: "__component0"_sapui_bInAfterRenderingPhase: trueaBeforeDelegates: Array[0]aDelegates: Array[0]bAllowTextSelection: truebOutput: truebSelectedDelayed: undefinediSuppressInvalidate: 0mAggregations: ObjectmAssociations: ObjectmBindingInfos: ObjectmBindingParameters: nullmBoundObjects: ObjectmElementBindingContexts: ObjectmEventRegistry: ObjectmMethods: ObjectmProperties: dmSkipPropagation: ObjectoBindingContexts: ObjectoModels: ObjectoParent: foPropagatedProperties: ObjectsBindingPath: nullsId: "__xmlview3--mainListItem2"sParentAggregationName: "items"__proto__: d_sLastMode: "SingleSelectMaster"_sOwnerId: "__component0"_sapui_bInAfterRenderingPhase: trueaBeforeDelegates: Array[0]aDelegates: Array[1]bAllowTextSelection: truebOutput: truebUseExtendedChangeDetection: trueiSuppressInvalidate: 0mAggregations: ObjectmAssociations: ObjectmBindingInfos: ObjectmBindingParameters: nullmBoundObjects: ObjectmElementBindingContexts: ObjectmEventRegistry: ObjectmMethods: ObjectmProperties: dmSkipPropagation: ObjectoBindingContexts: ObjectoModels: ObjectoParent: foPropagatedProperties: ObjectsBindingPath: nullsId: "__xmlview3--list2"sParentAggregationName: "content"__proto__: doPropagatedProperties: ObjectsBindingPath: nullsId: "__xmlview3--mainListItem2"sParentAggregationName: "items"__proto__: d
Regards,
Vamsi
Hi,
Can u try this
$('#listid:first-child').attr('selected',true);
Its selected using jquery!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.