0
votes

I am getting oData from backend.its data with timestamp and I need to get the difference from those timestamp.Which I did like bellow code.Now I want to add my that timestamp array to my view.Can I push those new array data to the view or how can I add update data to my sapui5 view. Bellow are the codes.xml view:

GenericTile class="cm_productTile sapUiMediumMarginTop" header="Flow" visible="{=${dataResults>/flowSelected}==='true'}"> /flow}" class="sapUiSmallMarginTop"> <core:Fragment fragmentName="castor.fua.FUAsapui5FE.fragments.flowMainNode" type="XML"/> <core:Fragment fragmentName="castor.fua.FUAsapui5FE.fragments.flowSubNode" type="XML"/>

var flowData = this.getView().getModel("elementsDataModel").oData.flow; //for (var i = 0; i < flowData.length; i++) {

                        console.log(flowData);

                        var differences = [];
                        for (var i = 0; i < flowData.length - 1; i++) {
                            var diff = new Date(flowData[i + 1].createdAt) - new Date(flowData[i].createdAt);
                            var diffMins = new Date(diff).getSeconds();
                            differences.push({diff:diffMins});
                        }

So differences array is the new data and I need to add those values in the view.

1

1 Answers

0
votes

If you can access the backend, best way is to calculate the timestamp difference in the backend and expose it as a property of your oDataModel. Alternatively (but I don't know if it fits your requirements) you can put your data coming from the oData model in a JSONModel, elaborate them and then bind this JSONModel with the new 'timestamp' column to the view.