开发者

How to add itemtap

I have a list and I cant get items in the list to be clickable. I have onItemDisclosure and that should work but it is not. I would like the whole row to be clickable but I cant seem to get anything to work.

    onItemDisclosure : function(record, btn, index) {
        //window.location = 'http://www.google.com';
    }

Here is my full source code

    Ext.ns("Course", "Course.stores");

Course = new Ext.Application({
  defaultTarget : 'viewport',
  name : 'Course',
  launch : function() {
    console.log('begin');

    this.viewport = new Ext.Panel({
      fullscreen : true,
      dockedItems : [ {
        title : 'Course Catalog',
        xtype : 'toolbar',
        ui : 'light',
        dock : 'top'
      } ],
      layout : 'fit',
      scroll : 'vertical',
      items : [ {
        xtype : 'list',
        itemTpl : '<span id="{letter}">{course}</span>',
        store : Course.stores.Properties,
        singleSelect : true,

        itemSelector : 'span.id',
        onItemDisclosure : function(record, btn, index) {
            //window.location = 'http://www.google.com';
        }
      } ],
      flex : 1
    });

  }
});

Ext.regModel('Properties', {
  fields : [ {
    name : 'letter',
    type : 'string'
  }, {
    name : 'course',
    type 开发者_StackOverflow中文版: 'string'
  } ]
});

Course.stores.Properties = new Ext.data.Store({
  model : 'Properties',  
  sorters: 'letter',
  getGroupString : function(record) {
        return record.get('letter')[0];
  },
  proxy : {
    type : 'ajax',
    url : '../lib/course_catalog.php',
    reader : {
      type : 'json',
    }
  },
  autoLoad : true
});


Try something like this:

items : [ {
    xtype : 'list',
    itemTpl : '<span id="{letter}">{course}</span>',
    store : Course.stores.Properties,
    listeners: {
        scope : this,
        itemtap : function(foo, bar, etc) {
            doSomething...
        }
  } ],


The reason that taps are not being handled is because you are overriding the itemSelector config:

itemSelector : 'span.id',

You should not do this, as Ext.List expects it to be a certain internally-set value in order to handle events on items properly. Simply removing this from your config should make it start working.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜