Forum Stats

  • 3,733,828 Users
  • 2,246,828 Discussions
  • 7,856,887 Comments

Discussions

How to filter JET Table Whilst Maintaining Buffered Edits

DaveArch
DaveArch Member Posts: 81 Red Ribbon

JET Version: 10.0

Hi Community

We are using BufferingDataProvider with an oj-table to buffer our table edits in conjunction with ListDataProviderView to handle filtering as per the cookbook example under Table --> Filtering.

We have a master-detail (table-to-table) layout where when the parent row is fetched, the child table is filtered. To do the filtering we are replacing the data provider each time as per the cookbook example.

The problem we have is that if a user inserts a new row into the child table and then selects a different parent row, the new row is lost because the data provider has been replaced.

Does anyone have a pattern/technique of being able to use something like BufferingDataProvider to track CRUD operations whilst being able to filter a table and retain inserts/updates/deletes?

// Simplified Example

// Declaration

this.salaryData = new ArrayDataProvider([],{
         keyAttributes: "salaryId",
});

this.salaryDataProvider = ko.observable(new BufferingDataProvider(this.salaryData));

// User adds row somewhere:

this.salaryDataProvider.addItem({
                                metadata: { key: 1001 },
                                data:   {
                                            salaryId: 1001,
                                            employeeId: 12345
                                        }
                                });                               


// User selects parent (parentId):

let filterCriteria = {
    op: '$or',
    criteria: [
        {
            op: '$eq', value:
                { employeeId: parentId }
        }
    ]
};

let listDataProvider = new ListDataProviderView(this.salaryData,
    { filterCriterion: filterCriteria }
);

this.salaryDataProvider(new BufferingDataProvider(listDataProvider));

// Table is filtered however buffered data provider has lost edits as it has been replaced

this.salaryDataProvider().getSubmittableItems()); // Returns null

Thanks

Best Answer

  • Christine Lei-Oracle
    Christine Lei-Oracle Member Posts: 2 Employee
    edited June 7 Accepted Answer

    Unfortunately, when a BufferingDataProvider is replaced, the data is refreshed and the buffered data is lost.

    When BufferingDP is used in detail table, avoid changing it's parent before saving the buffer.

Answers

Sign In or Register to comment.