cancel
Showing results for 
Search instead for 
Did you mean: 

How to change the json model property value ?

Jayakrishnan
Active Participant
0 Kudos

Hi All,

I am working on Custom SAPUI5 Application development. In my application scenario i need to maintain more than 3000 records(it is the maximum ) in my JSON Model and displaying in my sap.ui.table.

In my case i need to show these 3000 items in my ui table and map (sap.ui.vbm.GeoMap), in a single screen. So user can see the same data in two different representations.

The reason i chose json model is,if user select any one of the table rows the same need to be highlighted in my vbm map control and vice versa. so in my json model i introduces new boolean property called bSelect and enabled my json model for two way binding.

The default multi select option of the ui table will not suite for the scenario so i introduces new column for check box and bounded boolean value from my model. It works perfectly .

I am triggering Select all and Deselect all feature via additional button. When the maximum records is there, (i.e 3000), the delay is happening while changing the property.

This is my button press event code:

onSelectAllNotification: function (evt) {
var bSelectAll = evt.getParameter("selected");
var aNotificationCollection = this.getModel("oNotificationJsonModel").getProperty("/NotificationSet");
for (var iNotification = 0; iNotification < aNotificationCollection.length; iNotification++) 
    {
        aNotificationCollection[iNotification].selected = bSelectAll;
    }
this.getModel("oNotificationJsonModel").refresh();
},

Please help me to optimize more and avoid the delay? or is there any other optimized way to do ? Please suggest me.

Thank you,

Regards,

Jayakrishnan.

maheshpalavalli
Active Contributor

u mean the for loop is taking time or after the update of the selected property the UI refresh is taking time?

ricardo7227
Participant

I don't know if it can improve performance, but this is another way to do it

onSelectAllNotification: function (evt) {
	var bSelectAll = evt.getParameter("selected");
	var oModel = this.getModel("oNotificationJsonModel");
	var aNotificationCollection = oModel.getProperty("/NotificationSet");
	for (var iNotification = 0; iNotification < aNotificationCollection.length; iNotification++) {

	   oModel.setProperty("/NotificationSet/" + iNotification + "/selected", bSelectAll);
	} 
}
Jayakrishnan
Active Participant
0 Kudos

maheshkumar.palavalli ,

Hi Mahesh, it is not because of the loop i believe, when i do the debug i can see the for loop process does not took any time. it is because of binding mechanism with UI.

Thanks.

Jayakrishnan
Active Participant
0 Kudos

Hi ricardo7227 ,

Initially i tried the same approach. that is not working. If record is more than 1000, the page become unresponsive.

Thanks.

Accepted Solutions (0)

Answers (0)