Set Filter dynamically

Hi, I created data source in xml file and one filter with that data source. I am removing the items from datasource and adding new Items in controller. I want the new items added into the datasource should be add into the filter as well. But still filter pointing the old items of data source. Plz find the codes.

Below is the xml file code for datasource and filter


<groupDatasource id="plan_DatasDs"
                 class="com.keansa.keansacloud.entity.Plan_Data"
                 view="plan_Data-with-MDPLANUnits-MDMEASURE">
    <query>
        <!&#91;CDATA&#91;select e from keansacloud$Plan_Data e

&#93;&#93;>
<filter id="filter"
        applyTo="planDataGrid"
        datasource="plan_DatasDs">
    <properties include=".*"/>
</filter>

Below is the controller code.


public void createDataForDataAccordingToGroupByForDataGrid(){
    LoadContext<Plan_Data> loadContext = LoadContext.create(Plan_Data.class)
            .setQuery(LoadContext.createQuery("select e from abs$Plan_Data e"));
    loadContext.setView("plan");
    List<Plan_Data> planningViewList = dataManager.loadList(loadContext);
    for (Plan_Data plan_data:planningViewList){
        plan_DatasDs.removeItem(plan_data);
        filter_DatasDs.removeItem(plan_data);
    }
    List<Plan_Data> planningviewList = planningViewService.getPlanningViewListForAllPlanningViews("someValue1","someValue2");
    for(Plan_Data planData:planningviewList){
        plan_DatasDs.addItem(planData);
        filter_DatasDs.includeItem(planData);
    }
}

What do you mean by “filter” here? Another datasource? What is filter_DatasDs?
Better create a small test project demonstrating the issue and attach it here along with the steps to reproduce.

true,
Sorry, I forgot to remove f’ilter_DatasDs.includeItem(planData)’ statement. Please ignore that statement. Please check the points below for clarification.

  1. In xml file I have created Data source (‘plan_DatasDs’) and Filter (‘filter’).
  2. When first time page will load, I m writing the backed code with the group by query(Native Query) as per my requirement in controller and adding that data into the Data source (‘plan_DatasDs’).
    List<Plan_Data> planningViewList = dataManager.loadList(loadContext);
    for (Plan_Data plan_data:planningViewList){
    plan_DatasDs.removeItem(plan_data);
    }
    List<Plan_Data> planningviewList = planningViewService.getPlanningViewListForAllPlanningViews(“someValue1”,“someValue2”);
    for(Plan_Data planData:planningviewList){
    plan_DatasDs.addItem(planData);
    }
    filter.setDatasource( plan_DatasDs);
  3. I want to add that newly added data into the filter as well. But still filter taking the old data. I used the filter.setDatasource( plan_DatasDs), but its not working.