首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何刷新Ext.List

如何刷新Ext.List
EN

Stack Overflow用户
提问于 2013-09-17 09:48:08
回答 1查看 76关注 0票数 0

在我的应用程序im中,使用Ext.List显示来自JSON的内容,最初,当我添加搜索关键字时,JSON数据正确地显示了.If,来自JSON结果的响应被添加到以前的内容中,即,

初始表

代码语言:javascript
复制
 Car
 Bus
 Jeep

如果m搜索汽车,表显示在下面

代码语言:javascript
复制
 Car
 Bus
 Jeep
 Car

但是我只想显示新的结果,这里是代码

搜索

代码语言:javascript
复制
 {
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
       }
  }

搜索表

代码语言:javascript
复制
 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

代码语言:javascript
复制
 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帮助解决之前刷新或清除列表

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-09-17 10:12:36

试试这个:

代码语言:javascript
复制
searchfrieandtab.getStore().removeAll();
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18846543

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档