Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

ojTable not updating when bound to oj.ArrayTableDataSource based on computed

Jim.Marion-OracleMar 24 2016 — edited Mar 29 2016

I want to filter an ojTable bound to an oj.ArrayTableDataSource. I looked at Filtering - Fully-fetched Collection, which is based on oj.Collection. It uses the where method, which doesn't appear to exist in either oj.ArrayTableDataSource or oj.TableDataSource. My first thought was to wrap the oj.ArrayTableDataSource around a computed and filter the computed as described here: Jim's JavaScript Journal: Filtering Table Data with Knockout Computeds. I put together a fiddle of this here: https://jsfiddle.net/jmarion/0nfg10oL/2/ (requires an ES6 browser such as chrome or use the polyfilled version here: https://jsfiddle.net/jmarion/0nfg10oL/1/). Unfortunately, the table preview doesn't update when the computed recomputes. I put lots of console.log statements in the code, so open the console and notice that the computed does recompute and it does return just a subset. The ojTable just doesn't update. I've seen the Table - Using ko.observableArray example which seems to be just updating the underlying observableArray and the table updates to show array changes. This is why I thought a computed would be satisfactory.

Here is another version that does NOT use computeds, but uses the reset method instead: https://jsfiddle.net/jmarion/0nfg10oL/3/. This works great. Is this the way I'm supposed to filter an ojTable based on an oj.ArrayTableDataSource? Am I missing something?

This post has been answered by John JB Brock-Oracle on Mar 29 2016
Jump to Answer
Comments
Post Details
Added on Mar 24 2016
5 comments
1,426 views