PDA

View Full Version : Request LiveSearch example



parsbin
15 Mar 2011, 12:18 AM
Hi
i need an example of LiveSearch on json with php file.
the default example is obscure and I did not understand any thing of that, after 2 days.

parsbin
15 Mar 2011, 11:09 PM
not idea?

parsbin
15 Mar 2011, 11:31 PM
when i have input value in combobox, i don`t receive any answer.

my js code:


Ext.onReady(function(){

var ds = new Ext.data.Store({
proxy: new Ext.data.ScriptTagProxy({
url: 'http://localhost/ext/examples/form/test.php'
}),
reader: new Ext.data.JsonReader({
root: 'topics',
totalProperty: 'totalCount',
id: 'post_id'
}, [
{name: 'title', mapping: 'topic_title'},
{name: 'topicId', mapping: 'topic_id'},
{name: 'author', mapping: 'author'},
{name: 'lastPost', mapping: 'post_time', type: 'date', dateFormat: 'timestamp'},
{name: 'excerpt', mapping: 'post_text'}
])
});

// Custom rendering Template
var resultTpl = new Ext.XTemplate(
'<tpl for="."><div class="search-item">',
'<h3><span>{lastPost:date("M j, Y")}<br />by {author}</span>{title}</h3>',
'{excerpt}',
'</div></tpl>'
);

var search = new Ext.form.ComboBox({
store: ds,
displayField:'title',
typeAhead: false,
loadingText: 'Searching...',
width: 570,
pageSize:10,
hideTrigger:true,
tpl: resultTpl,
applyTo: 'search',
itemSelector: 'div.search-item',
onSelect: function(record){ // override default onSelect to do redirect
window.location =
String.format('http://extjs.com/forum/showthread.php?t={0}&p={1}', record.data.topicId, record.id);
}
});
});



my php code:


echo '
{"totalCount":"316636","topics":[{"post_id":"580952","topic_title":"ExtJS 4 beta\/release when?","topic_id":"120486","author":"joeraman","post_time":"1300253336","post_text":"Its informative post provides a lots of information related to topic also provide more information on topic.","forum_title":"Ext: Open Discussion","forumid":"6","reply_count":"87"},{"post_id":"580950","topic_title":"PagingToolbar doesnt work","topic_id":"126935","author":"maStarlette77","post_time":"1300253086","post_text":"Hi all,\n\nI implemented a pagingtoolbar for my J2ee project and this one doesnt work.I have the footer. but when I want to go to the previous or next...","forum_title":"Ext: Open Discussion","forumid":"6","reply_count":"0"}]}
';

moegal
16 Mar 2011, 1:12 AM
do you get a result from your data file if you run it alone?

http://localhost/ext/examples/form/test.php

Do you see the combobox on the page?

What kind of problem are you having?

fay
16 Mar 2011, 2:39 AM
Why are you using ScriptTagProxy (http://dev.sencha.com/deploy/dev/docs/?class=Ext.data.ScriptTagProxy) on your local server? Change it to HttpProxy (http://dev.sencha.com/deploy/dev/docs/?class=Ext.data.HttpProxy).