1. #1
    Sencha User
    Join Date
    Apr 2012
    Posts
    12
    Vote Rating
    0
    erinhir is on a distinguished road

      0  

    Default Unanswered: 5 easy questions

    Unanswered: 5 easy questions


    i am new to sencha touch and i have some simple questions. I don't need 100% working code as answers, but if someone could point me in the correct direction, this would be great. But keep in mind, sencha touch is new to me. I use sensha touch 1.x.
    Let me first explain what my app does. It shows a list with items (fetched from a db via json proxy). You can tap on a item, which shows a form. You can then update or delete the item. On the list screen you can also add a new item. Quite simple :-)
    Here are my questions:

    1/ Datepickerfield:
    In the form there is a datepickerfield. The default format is month/day/year. I live in Europe so the formate should be day/month/year. With slotorder I can change this. But the field itself still has the wrong format. I tried to fix this with a listener:

    change: function() {
    this.fieldEl.dom.value = this.getValue().format('d/m/Y'); }
    This works when selecting a date. But when tapping an item from the list, the datepickerfield remains the wrong format. I tried using other listeners like "afterrender", "scope", etc. But nothing works.

    2/ Numberfields:
    In the model I have a field "duration". It is of the type "time" in the sql-table. So the format is "hh:mms". In the form I have 3 numberfields. One for the hour, one for the minutes and one for the seconds. How can I make that the field "duration" is split up in 3 parts and filled in the 3 numberfields when tapping an items from the list?

    3/ Contextual selectfield
    In the form there is a selectfield with values that depend on the user that is logged in. If user 1 is logged in the values should be x,y,z. If user 2 is logged in, the values should be x, a, b. Etc.. So when opening the form the selectfield should be prefilled with data. It should call a function from the server to fetch the correct data. How can this be achieved?

    4/ Refresh list like twitter
    I want the list to fetch additional items when reaching the end (like twitter). I found something on the internet: PullRefresh plugin. But I can't make it work. Any ideas?

    5/ Style the list
    Is it possible to style each item of a list seperately? U can use styleHtmlCls, etc but that styles the whole list.

    Thanks a lot in advance.

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,073
    Answers
    3500
    Vote Rating
    854
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    1. The format being shown can be changed via changing the Ext.util.Format.defaultDateFormat to a format string of your choice.

    2. I personally would create my own field that handles the getValue and setValue to join or split the value to the child fields. So technically you have 1 field with 3 child fields.

    3. Whatever is in the store the select field will show. If that means you need to filter the data in the store then ok or if you need to load the store again then you need to do just that.

    4. Check out the request/response to see what is going on. Your statement is too generic to be able to help.

    5. In your itemTpl, surround everything in a <div> and give it a class. You can then style that element.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Apr 2012
    Posts
    12
    Vote Rating
    0
    erinhir is on a distinguished road

      0  

    Default


    Thanks for the responses. Some additional questions ;-)

    1. The format being shown can be changed via changing the Ext.util.Format.defaultDateFormat to a format string of your choice.

    Can you give some more explanation? Maybe some peudocode?

    2. I personally would create my own field that handles the getValue and setValue to join or split the value to the child fields. So technically you have 1 field with 3 child fields.

    Same as for question 1, is more explanation possible? Maybe a short example?

    thanks
    Erinhir


  4. #4
    Sencha User
    Join Date
    Apr 2012
    Posts
    12
    Vote Rating
    0
    erinhir is on a distinguished road

      0  

    Default


    For those who are interested, my solutions.

    1/ This code Ext.apply(Ext.util.Format, {defaultDateFormat: 'd/m/Y'}); which sets the format for all the dates in the application.

    2/ I created in my model 3 extra fields. It are 3 "convert" fields for the field "duration" which is in format "hh:mms". This is the code (the same for the fields duration_m and duration_s):
    PHP Code:
    name'duration_h'
                
    convert: function(valuerecord
    {
               var 
    durationrecord.get('duration'), 
                     
    splits    duration.split(":"), 
                     
    duration_h splits[0];
               return 
    duration_h;             

    In my form I use now 3 numberfields linked to those 3 extra fields. When saving you data you must not forget to do
    PHP Code:
    model.set('duration_h'''); 
    Otherwise those fields are not set in the model and keep being empty.

    3/ and 4/ I did not yet solved.