cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

sap.m.Table refresh items

aabhas_wilmar
Contributor
0 Likes
5,068

Hi All,

I have created a simple app which has a view with a SearchField and Table. The search field also has liveChange feature and when the function is called, I call my query to backend system using oModel.read().

In the SearchField, the user can type either a material number or material description and as a result of liveChange, data is displayed in the table below the SearchField

When I delete the typed in text, the search results adjust accordingly, and when the searchfield is empty, no data is shown:

Problem: The problem begins when I start typing in the search field again, it appears that the table has lost its items cells structure.

The above view was created in XML.

I have created the same view in JS and it works fine.

Any suggestions? Please ask for more information and I will provide it as required.

Thanks.

View Entire Topic
aabhas_wilmar
Contributor
0 Likes

Resolved using the following code:


onInit: function() {

     var oTab = this.getView().byId("idTblMat");

     oTab.setModel(oJsonModelS);

     oTab.bindItems("/results", this.getView().byId("idColListItem") , null, null);

},


liveChange


onSearch : function (oControlEvent) {

     var sPlant = this.getView().byId("idSelPlant");

     var oTab = this.getView().byId("idTblMat");

    

     var sQuery = oControlEvent.getParameter("newValue");

     if (sQuery) {

          oModelS.read("/MaterialSet?$filter=Werks eq '"

          +sPlant.getSelectedKey()+

          "' and Maktg eq '"

          +sQuery+

          "' and Matnr eq '"

          +sQuery+

          "' ",

          null,null,false,function(oData,repsonse){

          oJsonModelS.setData(oData);

          oTab.bindItems("/results", sap.ui.getCore().byId("idColListItem") , null, null);

     });

     } else {

          oJsonModelS.setData();

     }

},