How to have the slide multiple screens in Sench touch

匆匆过客 提交于 2019-12-13 15:22:37

问题


I am developing an application in which when submit button is clicked in the form, it should go to a different screen. However it is just printing the results outside of the window and not really going to a new screen. I have hardcoded the store to make sure there is data when I start the application and it still prints it outside of the viewable area.

Here is my Ext.data.Store:

var store = new Ext.data.Store({
  model: 'jobSummary',
  storeId: 'jobStore',
  data : [{title: 'This is test'},
    {title: 'This is test2'},
    {title: 'This is test3'}]
});

Here is the list that I am using it in:

SearchJobsForm.jobsList = Ext.extend(Ext.Panel, {
  dockedItems : [ {
    xtype : 'toolbar',
    title : 'WTJ',
    dock : 'top',
    items : [ {
      xtype : 'button',
      text : 'Back',
      ui : 'back',
      handler : function() {
        //back button controller
      },
      scope : this
    } ]
  } ],
  items : [ {
    xtype : 'list',
    emptyText : 'No data available.',
    store : 'jobStore',
    itemTpl : '<div class="list-item-title">{title}</div>' 
    +
      '<div class="list-item-narrative">{narrative}</div>',
    onItemDisclosure : function(record) {
    },
    grouped : false,
    scroll : 'vertical',
    fullscreen : true
  } ],
  initComponent : function() {
    SearchJobsForm.jobsList.superclass.initComponent.apply(this, arguments);
  }
});

And i am calling this list panel from my submit button handler which is:

var jobsList = new SearchJobsForm.jobsList();

The full code I have pasted on this link for better visibility: http://pastebin.com/a05AcVWZ


回答1:


Ok,

SearchJobsForm.form is your main panel, it will contains two components a searchForm (with text/select input) and a panel/list of results. In the callback, we will hide() the form and show() the results list. This is not a clean code, but the simpliest and kissest one I can get from yours.

  • First let's instantiate the jobsList

// It has the id ( id: 'jobsListId')

var jobsList = new SearchJobsForm.jobsList();
  • then you should put all your inputs into a form (xtype : formpanel, id: 'searchFormId')
  • And add the resultPanel just after the form

Here is the code

SearchJobsForm.form = Ext.extend(Ext.Panel,{

    initComponent: function(){

        Ext.apply(this, {
            id: 'searchForm',
            floating: true,
            width: 250,
            height: 370,
            scroll: 'vertical',
            centered: true,
            modal: true,
            hideOnMaskTap: false,
            items: [
            {
                xtype: 'formpanel', // 1. this is the added formpanel
                itemId: 'searchForm',
                id:  'searchFormId', // this id is important
                items: [
                {  
                    xtype: 'textfield',
                    ...
                }, {
                    xtype: 'textfield',
                    ...

                },
                // all your inputs 
                ]
            },
                // 2. add here the results panel : jobsList
                jobsList
            ],  // the code continues inchanged
                dockedItems: [{
                              ...

- Finally we will modify the ajax callback to hide/show the panels. Do not remove one of them, elsewhere you won't be able to reset your form

// here it comes

        Ext.util.JSONP.request({
            url: "http://"+serverAdd+":"+ port+"/users/searchresults.json", 
            format: 'json',
            callbackKey: 'callback',
            params : searchCriteria,                
            callback: function(data) {
                console.log('callback');
                // Call your list-filling fonctions here
                // jobsList.fill(data);
                Ext.getCmp('searchFormId').hide();
                Ext.getCmp('jobsListId').show();

            },
            failure: function ( result) { 
                console.error('Failed'); 
            }
        }); 

For your next projects, I recommend you to work with classes and namespaces to avoid 1000 lined files ; Ext.ns() is your best friend and will avoid you a lot of headaches.



来源:https://stackoverflow.com/questions/8929322/how-to-have-the-slide-multiple-screens-in-sench-touch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!