Results 1 to 4 of 4

Thread: live search combo results flashing quickly then disappearing

  1. #1
    Sencha User
    Join Date
    Aug 2009
    Location
    Tamworth, NSW, Australia
    Posts
    32

    Question live search combo results flashing quickly then disappearing

    I've been using the following example as my reference:

    http://dev.sencha.com/deploy/dev/examples/form/forum-search.html

    But I've got it almost working except that the results returned from my server are being received, but not shown in the drop-down below the combo box. I can see it appear for a fraction of a second then disappear. I know I'm receiving results because I'm watching them through FireBug in Firefox. I've tried adding/removing all kinds of config options but none seem to change this strange behaviour. I've obviously done something wrong, but haven't a clue what. here's the relevant parts of my ExtJS code:

    Code:
    var resultTpl = new Ext.XTemplate([
        '<tpl for="."><div class="search-item">',
            '<span><b>{wo}</b><br>{al}<br>{me}</span>',
        '</div></tpl>'
    ]);
    
    var search_store_english = new Ext.data.Store({
        url: 'php/search_english.php',
        reader: new Ext.data.JsonReader({
            root: 'data',
            totalProperty: 'number',
            idProperty: 'id'
        }, vocab_model)
    });
    
    var vocab_model = Ext.data.Record.create([
        {name: 'id', type: 'int'},
        {name: 'wo', type: 'string'},
        {name: 'wp', type: 'string'},
        {name: 'al', type: 'string'},
        {name: 'ap', type: 'string'},
        {name: 'gr', type: 'string'},
        {name: 'me', type: 'string'},
        {name: 'ty', type: 'string'},
        {name: 'er', type: 'int'},
        {name: 'se', type: 'string'},
        {name: 'da', type: 'date', dateFormat: 'Y-m-d H:i:s'}
    ]);
    
    
    
    xtype: 'combo',
    typeAhead: false,
    loadingText: 'Searching...',
    hideTrigger: true,
    width: 500,
    pageSize: 5,
    itemSelector: 'div.search-item',
    displayField: 'wo',
    autoSelect: true,
    store: search_store_english,
    tpl: resultTpl,
    mode: 'remote',
    onSelect: function(record) {
        Ext.Msg.show({
            title: 'Selection',
            msg: 'You chose "' + record.data.wo + '"',
            buttons: Ext.Msg.OK
        });
    }
    This obviously isn't all the code. There's SO much of it, but these (I hope) are the relevant parts. I can post the PHP if requested, but it shouldn't be the problem, I don't think. Here's the JSON received by the browser for one of the example searches:

    Code:
    {"success":true,"error":0,"message":"","data":[{"id":"125","wo":"aud\u0101ci-a","wp":"audaci-a","al":"ae","ap":"ae","gr":"1f","me":"boldNESS, cockiNESS","ty":"n","er":"2","se":"1","da":"2010-07-17 20:58:00"},{"id":"126","wo":"aud\u0101x","wp":"audax","al":"aud\u0101c-is","ap":"audac-is","gr":"","me":"brave, bold, resolute","ty":"adj","er":"2","se":"1","da":"2010-07-17 20:58:00"}],"number":2}
    It's a database of Latin words that I'm searching the "meaning" field (or "me" for short) to find words in English matching the Latin equivalent. E.g., searching for "bold" returns the above two records: "aud?ci-a" and "aud?x".

  2. #2
    Sencha User
    Join Date
    Aug 2009
    Location
    Tamworth, NSW, Australia
    Posts
    32

    Default

    Through a process of elimination I found the cause of the problem: me trying to re-use a data record from elsewhere in my system. If I copy and paste the definition of that record where I'm just referring to the variable "vocab_model", it's working.

    Is there a way I can re-use an existing model rather than having to define it in two places to keep the search happy? If not, then I suppose I'll live :-)

  3. #3
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,892

    Default

    Of course you should define a record only once!

    You don't define multiple classes to encapsulate business objects on your server tier do you?

    What's your application's namespace?

  4. #4
    Sencha User
    Join Date
    Aug 2009
    Location
    Tamworth, NSW, Australia
    Posts
    32

    Default

    Quote Originally Posted by Animal View Post
    What's your application's namespace?
    Having though about it, I probably don't need so many fields for what I'm planning to do with the live search box, but I'm not sure what you mean about my application's namespace. So far I have one html file with some border layouts, some grids, etc. Not much else, and only a few PHP scripts.

Similar Threads

  1. Live Search Combo Box - Results Not Displaying
    By scblue in forum Ext 3.x: Help & Discussion
    Replies: 1
    Last Post: 14 Jul 2010, 12:19 AM
  2. Combo live search query not sent
    By manube in forum Ext 3.x: Help & Discussion
    Replies: 1
    Last Post: 4 Feb 2010, 2:58 AM
  3. Live Search renders no results
    By vaduros in forum Ext 1.x: Bugs
    Replies: 2
    Last Post: 2 Apr 2007, 4:07 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •