on 05-06-2014 6:51 PM
Hello Experts,
What I am looking out for is to refresh or reload data into SAPUI5 table. The model associated with the table is a JSON model. Is there an option to refresh the table or reload data into the JSON model and then the table?
Basically I want the whole table to be refreshed on click of an image in the table column. Any help would be really helpful. Thanks in advance.
Thanks & Regards,
Archana
Hi,
i am using this
sap.ui.getCore().byId("mytableid").getModel().refresh(true);
in my JSON MODEL but it doesn't working,
please help me, how to refresh the UI5 table data with synatax
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Yoppie,
In case you are trying to access the view "idmytableview" from different view, Just check if the view "idmytableview' is loaded. If this view is not loaded, this corresponding view or its contents will not be available and returns Undefined.
If not, in which context are you getting this error.
Regards,
Ravikiran
Hi Yoppie,
If i am correct, you should be using XML view.
Can you check below this line of code,
this.getView().byId("idmytableview");
Regards,
Ravikiran
Hi All,
I have a case of resetting the model on click of a button, i tried this method.
sap.ui.getCore().byId("THE_ID_OF_YOUR_VIEW").getModel().refresh(true);
I am able to call the view and model as well, but not able to refresh the model, which says "undefined".
Am I missing something here, please correct me if wrong.
Thanks,
Ravikiran
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for your reply guys.As Robin said, I am reexecuting the AJAX call to DB. I thought there would be some API using which I can trigger the refresh and AJAX call.
But this reexecution is working for me. SO, thats fine.
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:
sap.ui.getCore().byId("THE_ID_OF_YOUR_VIEW").getModel().refresh(true);
Best, Silvia
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
model.refresh(true);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Honestly, I have never felt the need to use any of the UI5 refresh or invalidate methods yet
Normally, if your table is bound to your model, any changes you do to the model (whether via user interaction or updating via REST etc) would instantly be reflected in your table (or any other controls bound to your model)
Thanks Robin. Completely agree to your point. Let me explain what I want to achieve.
I have a table bound to a JSON model. Now, I need to reload the same JSON data again on click of an Image in the table column(Obv, the data changes in the backend. Hence the data in JSON again needs to be refreshed.)
I am looking out for an option to achieve this. If I do table.invalidate and table.rerender, it isnt changing the JSON data which is what I am looking for. I just want to avoid calling the DB again and again.
I hope this can be achieved in some way.
Thanks & Regards,
Archana
If the data is changed on the backend you just re-execute the ajax call to retrieve the JSON table data from your backend, and your table automagically displays the updated data.
And if you make changes to the table data from the frontend, your JSON should also be updated and your table displays the same updated data.
On a sidenote, if the data on the backend differs from what is displayed in the frontend, you should always update your frontend with the data from your backend to avoid synchonization / data mismatch issues
It sounds like you're updating the JSON directly -- when you create the model, (e.g. new sap.ui.model.json.JSONModel(this.modelData) ) the source JSON is cloned into the model, and you need to use the set*() methods of sap.ui.model.json.JSONModel to update the model. I'd actually advise you *not* to keep a JSON object outside the model, since this copy would not get any updated values from the view bindings.
| User | Count |
|---|---|
| 3 | |
| 3 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.