Skip to Content
avatar image
Former Member

Table Rows Deletion from UI

Hi All,

I am working on sapui5 app and stuck in deleting the unnecessary rows.

I am using xml View and i have a questionTable which is binded

items="{path: '/AuditToCreate/QuestionsSet', sorter: {path: 'rootValue', group: true }}"

From oData service I am getting 5 records. However based on certain condition I want to display only 3 records.

I did use splice and now /AuditToCreate/QuestionsSet has only 3 records. Which is good.

But the problem , when user is saving (click on save button)in payload which is sent to backend should have all 5 objects as is.

so, I tried removing the items from UI using removeItem . But still it has 5 records. And empty rows are still visible.

How can I achieve so that on UI only 3 rows are visible but model has 5 rows.

var oTable = this.getView().byId("idQuestionCreateTbl");

var oCreateData = this._oModel.getProperty("/AuditToCreate");
var oTemplateName = this._oModel.getProperty("/AuditToCreate/templateName");              

 for (var i6=0; i6<oCreateData.QuestionsSet.length; i6++) { 

      if(oTemplateName === oCreateData.QuestionsSet[i6].ExternalId){
      oTable.removeItem(oCreateData.QuestionsSet[i6]);
}
            }
Add comment
10|10000 characters needed characters exceeded

  • Former Member

    Please note , I dont want Delete or Remove button. When ever the Table is loaded unnecessary rows should not show up.

    Any pointers would be helpful.

    regards

    Fehmina

  • Get RSS Feed

1 Answer

  • Jul 28, 2017 at 06:28 PM

    Set visibility for item instead of removing item.

    Assuming you are using sap.m.Table, in XML view set a formatter for list item. Purpose of this formatter is to read the attribute name 'templateName' and perform necessary check that returns a boolean(true/false). Since this boolean value is set to 'visible' property of list item corresponding item will be hidden from display but model still contains all the records.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Thank you Srikanth for the response. Yes i tried visibility but rows were still visible(empty rows).

      So i used Filters and it resolved my problem.\

      Thanks

      Fehmina.