Sencha Touch FormPanel 带商店

发布于 2024-12-06 16:11:43 字数 1649 浏览 0 评论 0原文

我有一家商店如下。

var eventsStore = new Ext.data.Store({
    model: 'Event',
    sorters: [{
        property: 'OccurringOn',
        direction: 'DESC'
    }],
    proxy: {
        type: 'ajax',
        url: BaseURL + 'Events.php',
        api: {
            read: BaseURL + 'Events.php',
            create: BaseURL + 'Events.php'
        },
        reader: {
            type: 'xml',
            root: 'Events',
            record: 'Event'
        },
        writer: {
            type: 'xml',
            writeAllFields: false,
            root: 'Events',
            record: 'Event'
        }
    },
    getGroupString: function(record) {
        if (record && record.data.OccurringOn) {
            console.log(record.get('OccurringOn'));
            return record.get('OccurringOn').toDateString();
        }
        else {
            return '';
        }
    }
});

我还有一个列表视图,可以很好地显示所有事件。我有一个允许用户添加新事件的表单,并且我有 FormPanel。 FormPanel 的工具栏上有“保存”按钮,单击该按钮将执行以下操作。

var eventCard = It's a card

var newEventCard = eventCard.items.items[1];

var currentEvent = newEventCard.getRecord();

newEventCard.updateRecord(currentEvent);

var errors = currentEvent.validate();

// here I check errors and prompt user about them

var eventList = eventCard.items.items[0].items.items[0];
var eventStore = eventList.getStore();

eventStore.add(currentEvent);
eventStore.sync();
eventStore.sort( [ { property: 'OccurringOn', direction: 'DESC' } ] );
eventList.refresh();

上面的代码向 MySQL 数据库添加了两个空行,并使用 3 个空的新项目复制事件列表视图项目。为什么这是这种行为以及我所缺少的?

如果您能告诉我同步时将哪些参数作为 POST 发送到 Events.php,我将不胜感激。

I have a store as follows.

var eventsStore = new Ext.data.Store({
    model: 'Event',
    sorters: [{
        property: 'OccurringOn',
        direction: 'DESC'
    }],
    proxy: {
        type: 'ajax',
        url: BaseURL + 'Events.php',
        api: {
            read: BaseURL + 'Events.php',
            create: BaseURL + 'Events.php'
        },
        reader: {
            type: 'xml',
            root: 'Events',
            record: 'Event'
        },
        writer: {
            type: 'xml',
            writeAllFields: false,
            root: 'Events',
            record: 'Event'
        }
    },
    getGroupString: function(record) {
        if (record && record.data.OccurringOn) {
            console.log(record.get('OccurringOn'));
            return record.get('OccurringOn').toDateString();
        }
        else {
            return '';
        }
    }
});

I also have a List view which gets all Events fine. I have a form which allows user to add new event and I have FormPanel for it. The FormPanel has Toolbar which has Save button which when clicked will do following.

var eventCard = It's a card

var newEventCard = eventCard.items.items[1];

var currentEvent = newEventCard.getRecord();

newEventCard.updateRecord(currentEvent);

var errors = currentEvent.validate();

// here I check errors and prompt user about them

var eventList = eventCard.items.items[0].items.items[0];
var eventStore = eventList.getStore();

eventStore.add(currentEvent);
eventStore.sync();
eventStore.sort( [ { property: 'OccurringOn', direction: 'DESC' } ] );
eventList.refresh();

The above code adds two empty rows to the MySQL database and copies the event list view items with 3 empty new items. Why this is the behavior and what I am missing?

If you can tell me what parameters are sent as POST to the Events.php when I sync that would much appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

玩物 2024-12-13 16:11:43

我发现这是我的错。当有对服务的 POST 请求时,我正在回显。

It was my fault I figured out. I was echo'ing when there was POST request to the service.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文