如何刷新我的项目列表在winapp当我插入一个新的数据在sqlite (javascript &html)

how to refresh my itemlist in winapp when I insert a new data in sqlite (javascript & html)

本文关键字:一个 sqlite html javascript 数据 我的 刷新 何刷新 项目 列表 winapp      更新时间:2023-09-26

我插入一个新的数据到sqlite(与buttonclick),然后如何刷新我的项目列表,这样我就可以看到新的数据,而无需重新启动应用程序。我使用javascript&html制作一个win8app.

我没有在应用程序中使用数据绑定。

 // Because we're doing the rendering, we need to put the data into the item.
        // We can't use databinding.
        result.getElementsByClassName("item-image")[0].src =currentItem.data.backgroundImage;
        result.getElementsByClassName("item-note-day")[0].textContent = currentItem.data.noteDay;
        result.getElementsByClassName("item-iconClassImage")[0].src = currentItem.data.iconImage;
        result.getElementsByClassName("item-noteTitle")[0].textContent = currentItem.data.noteTitle;
        result.getElementsByClassName("item-noteExcerpt")[0].textContent = currentItem.data.noteContent;
        return result;

我想要的是当我点击按钮,我插入我的数据到sqlite和listview刷新,所以我可以看到我所有的数据包括新的一个。我成功地将我的数据插入sqlite。

对不起,我是中国人,这是我第一次用英语提问。我不,我清楚了吗?如果有人能帮助我,谢谢。

对于这个SQLite组件,有两种方法。第一个是简单的:

  1. 使用组件提供的itemDataSource(参见示例的单元测试)
  2. 当数据发生变化时,调用invalidateAll。从为数据库上的插入事件注册的侦听器或通过触发它的特定于应用程序的事件

这里的问题当然是它总是会重新加载整个列表。如果您希望有一个动态列表,它不会在每次更新时都访问数据库,第二种方法是实现您自己的IListDataSource接口,这可能会变得复杂得多。我为我们的应用程序做了这个,目前正在为我的一个宠物项目做一个抽象和可重用的版本,但不幸的是,我不能给出任何关于何时准备发布的时间表…