Skip to Content

ODATAModel Table binding delay problem

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();

},

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Oct 01, 2015 at 12:44 PM

    oTablePriority.bindItems("/NotificationPriorityCollection",

    ........

    var binding = oTablePriority.getBinding("items");

    if(binding)

    {

    binding.attachDataReceived(function () {

    dialogTablePriority.setTitle("Priority("+oTablePriority.getItems().length + ")");

    }, this);

    }

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Oct 01, 2015 at 09:54 AM

    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.

    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.