on 10-01-2015 10:31 AM
Hi,
I'm using sap.m.Table inside dialog box and binding ODATAModel .
my problem is i'm counting number rows in table (using oTable.getItems().length) and displaying as dialog box titile( ex: Lines(10))
due to more number of records binding is taking time
and count is displaying as "0" .
my code :
onClickPriority: function() {
var oTablePriority = new sap.m.Table(
{
inset: true,
headerDesign: sap.m.ListHeaderDesign.Standard,
mode: sap.m.ListMode.None,
});
var col = new sap.m.Column(
{
});
oTablePriority.addColumn(col);
var col1 = new sap.m.Column(
{
header: new sap.m.Label({
text: "Priority"
})
});
oTablePriority.addColumn(col1);
var col2 = new sap.m.Column(
{
header: new sap.m.Label({
text: "Priority Text"
})
});
oTablePriority.addColumn(col2);
var dialogTablePriority = new sap.m.Dialog({
content: [oTablePriority],
beforeOpen: function(){
var oModelPriority = new sap.ui.model.odata.ODataModel("http://xxxxxxxxxxxxxxxxxx_SRV/");
oTablePriority.setModel(oModelPriority);
oTablePriority.bindItems("/NotificationPriorityCollection",
new sap.m.ColumnListItem({
cells: [new sap.m.RadioButton({
select: function(evt) {
var pathno = evt.getSource().getBindingContext().getPath();
var in1 = pathno.split("/");
index = in1[1]; // Index
}
}),
new sap.m.Text({
text: "{Priority}"
}),
new sap.m.Text({
text: "{PriorityText}"
})]
}));
},
afterOpen : function(){
dialogTablePriority.setTitle("Priority("+oTablePriority.getItems().length + ")");
},
beginButton: new sap.m.Button({
text: 'Select',
press: function() {
var Priority = oTablePriority.getModel().oData[index].Priority;
var PriorityText = oTablePriority.getModel().oData[index].PriorityText;
oView.byId('Priorityid').setValue(Priority);
oView.byId('PriorityTextid').setValue(PriorityText);
dialogTablePriority.close();
}
}),
endButton: new sap.m.Button({
text: 'Cancel',
press: function() {
dialogTablePriority.close();
}
}),
beforeClose: function(){
var allItems = oTablePriority.getItems();
var len = allItems.length;
console.log(len);
}
});
dialogTablePriority.open();
},
oTablePriority.bindItems("/NotificationPriorityCollection",
........
var binding = oTablePriority.getBinding("items");
if(binding)
{
binding.attachDataReceived(function () {
dialogTablePriority.setTitle("Priority("+oTablePriority.getItems().length + ")");
}, this);
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Venkatachala,
Rather than fetching the length using oTable.getItems(), why don't you achieve the same using model.
Try -
dialogTablePriority.setTitle(sap.ui.getCore().getModel().getProperty("/NotificationPriorityCollection").length);
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.
it seems like your dialogTablePriority object is not initialized on your afterOpen event. please make sure you get a handle of the dialog before you can use that object.
once you have a handle of the correct object, then you can access its properties. it will be something like
var dialog = sap.ui.getCore().byId(idOfYourDialogObject);
then you can use your one line inside your afterOpen event.
I suggest to add a breakpoint and see if you got the correct object
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
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.