开发者

Form Data Access in Sencha Touch

I have been using forms in Sencha touch, but it seems that getting to the data can be a pain. I want to load data into a form based on localStorage values, and have it update when the localStorage is changed.

On creation of the page, it creates the form using the initial localStorage values, but when the the values get updated in localStorage, and the page gets viewed again the data is not updated. I know I can use an activate handler to load the values again on pageview. My problem is updating the form. The only way I have found to dynamically update a previously created form is by creating a record, model, and store. That seems over the top just to load one instance of record data into a form. This method seems like having a function insert a single variable in开发者_StackOverflowto a database just to retrieve it into a new variable to use, instead of just using the original variable itself.

Since I am just displaying data, not having the user modify it, I considered using an XTemplate, but it looks like that also needs to load from a store.


The setValues() method not work to update the values?

myForm = new Ext.form.FormPanel({
    fullscreen: true,
    items: [{
        xtype: 'textfield',
        label: 'text1',
        name: 'text1'
    },{
        xtype: 'textfield',
        label: 'text2',
        name: 'text2'
    }]
});
myForm.setValues({text1: "1", text2: "2"});

so you could include onActivate an myForm.setValues(eval(localStorage.formValues)) as long as you store a valid JSON object in localStorage.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜