在我的应用程序im中,使用Ext.List显示来自JSON的内容,最初,当我添加搜索关键字时,JSON数据正确地显示了.If,来自JSON结果的响应被添加到以前的内容中,即,
初始表
Car
Bus
Jeep如果m搜索汽车,表显示在下面
Car
Bus
Jeep
Car但是我只想显示新的结果,这里是代码
搜索
{
xtype: 'button',
ui:'normal',
width:'20%',
text: 'Search',
handler: function()
{
App.gvars.keywd=Ext.getCmp("searchfd").getValue();
searchfriends();
Ext.StoreMgr.get('searchfriendslist1').load();// i have added the method to refresh table but no use
}
}搜索表
var searchfrieandtab= Ext.create('Ext.List', {
width: 320,
height: 290,
id : 'searchfriendslist1',
itemTpl: ['<div style="margin:0px;background:#fff;" >'+
'<table style="margin:0px;padding:0px;height:40px;" width="100%" >'+
'<tr><td style="padding:2px 5px;width:90%;"><span><img src="data:image/jpeg;base64,{userImage}"/>'+
'</span><span>{userFirstName}</span></td>'+
'<td style="padding:2px 10px;width:10%;">'+
'<img src="resources/img/addplus.png" onclick="invitefriends(\'{userId}\')"/>'+
'</td></tr></table></div>'].join(),
listeners : {
itemtap: function (list, index, item, record, senchaEvent) {
if (senchaEvent.event.target.nodeName == 'IMG') {
var data = record.getData();
var userId = data.userId;
var itemPurchased = data.itemPurchased;
invitefriends(userId);
}
}
}
});JSON
function searchfriends() {
alert(App.gvars.keywd);
Ext.Ajax.request({
url: App.gvars.apiurl + 'SearchFriends/userID='+App.gvars.userid+'/keywords='+App.gvars.keywd,
method: "GET",
useDefaultXhrHeader: false,
withCredentials: true,
success: function (response) {
var respObj = Ext.JSON.decode(response.responseText);
Ext.getCmp('searchfriendslist1').setData(respObj.searchFriends);
},
failure: function (response) {
var respObj = Ext.JSON.decode(response.responseText);
Ext.Msg.alert("Error",response.responseText);
}
});
}如何在JSON call.Please帮助解决之前刷新或清除列表
发布于 2013-09-17 10:12:36
试试这个:
searchfrieandtab.getStore().removeAll();https://stackoverflow.com/questions/18846543
复制相似问题