Skip to Content

Get rendered table after applying filter on sap.ui.table

Hi community,

Is there some event triggered after applying a filter on the sap.ui.table where I can see all new filtered items?

My objective is to make specific cells of the table non-editable, after the filtering function and rerendering of the table. Here's my code (this function is called from a checkbox in the view):

applyFilter: function(oEvent){
this._theFilter = new Filter([caseFilter, oFilter], true);
this._oTable.getBinding("rows").filter(this._theFilter, "Application");
sap.ui.getCore().getComponent("__component0").getModel("theMainDataModel").refresh(true);
}

I can't get the table in onAfterRendering() function because it never goes there after the filtering... I also tried adding the filter function in sap.ui.table element but it also doesn't go there. I have tried adding .getBinding("rows").attachChange() function but there I can only see the aIndices[] where it shows which items from the model are filtered, but I don't get the table...

Do you have any suggestion how I can get the filtered table? (Keep in mind - the filtering works, I just don't know how to get the table in the code after it's filtered)

Thanks,

Sashko.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Jan 12, 2017 at 04:25 AM

    Hello Sashko,

    Please try something like below:

       var oTable2 = sap.ui.getCore().byId("oTable");    //Get hold of Table
       oTable2.addEventDelegate({                        //Table onAfterRendering event
          onAfterRendering: function() {                 
            var oBinding = this.getBinding("rows");      //Get hold of binding aggregation "row"
            oBinding.attachChange(function(oEvent) {     //Attach 'binding' change event which fires on filter / sort
              var oSource = oEvent.getSource();
              var oLength = oSource.getLength();
              alert("Filtered Length: " + oLength);
            })
          }
        }, oTable2);

    Here is a sample: Table afterFilter event

    It might fire two times, but I hope you can work on it ;-)

    Have a Nice Day!

    Best Regards,

    Sai.

    Add comment
    10|10000 characters needed characters exceeded

  • Jan 15, 2017 at 09:40 PM

    Is there someone else with a suggestion on this matter?

    Add comment
    10|10000 characters needed characters exceeded