Ext 搜索框的制作

本文介绍了如何在Ext.js中创建一个搜索框功能。通过定义`knowledgeBaseModel`数据模型和设置`Ext.data.Store`来处理请求数据。搜索条件包括关键字、标题和内容,根据用户输入的值动态更新额外参数,并加载数据。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Ext 搜索框的制作

Ext.define('knowledgeBaseModel', {
extend : 'Ext.data.Model',
fields : [ {
name : 'classification',
mapping : 'classification'
}, {
name : 'clicks',
mapping : 'clicks'
}, {
name : 'committime',
mapping : 'committime'
}, {
name : 'id',
mapping : 'id'
}, {
name : 'keyword',
mapping : 'keyword'
}, {
name : 'status',
mapping : 'status'
}, {
name : 'title',
mapping : 'title'
}, {
name : 'contentss',
mapping : 'contentss'
}  ]
});


// 请求数据
var knowStore_2 = Ext.create('Ext.data.Store', {
model : 'knowledgeBaseModel',
// id : 'knowStore',
pageSize : 15,
proxy : {
type : 'ajax',
url : 'findReviewed.action',
reader : {
// 数据格式为json
type : 'json',
root : 'root',
totalProperty : 'total'
},
extraParams : {
'workOrderTDTO.id' : '',
'workOrderTDTO.title' : '',
'workOrderTDTO.classification' : '',
'workOrderTDTO.keyword' : '',
'workOrderTDTO.clicks' : '',
'workOrderTDTO.committime' : '',
'workOrderTDTO.status' : 5
}
},
autoLoad : false
});


var tPanel_1 = Ext.create("Ext.panel.Panel", {
border : false,
bodyStyle: {  
        background: '#dae5f3',  
    }, 
layout: {
        type: 'hbox',
        align: 'right'
    },
items: [
   { 
xtype : "radio",
boxLabel : "知识关键词",
name : "demo1",
checked : true,
id : 'keywordManage',
margin : '0 5 0 0'
}, {
xtype : "radio",
boxLabel : "标题",
name : "demo1",
id : 'titleManage',
margin : '0 5 0 0'
}, {
xtype : "radio",
boxLabel : "内容",
name : "demo1",
id : 'contentManage',
margin : '0 122 0 0',
}
]
});


var bPanel_1 = Ext.create("Ext.panel.Panel", {
border : false,
bodyStyle: {  
        background: '#dae5f3',  
    },
    layout: {
            type: 'hbox',
            align: 'right'
        },
    items: [
            { 
    xtype : "textfield",
    margin : '0 5 0 0',
    id : 'contentTextManage',
    width : 240
    }, {
    xtype : 'button',
    text : "<img/>&nbsp;搜索",
    handler : function() {
    doTopSearch_1();
    },
    id : "queryBtnManage",
    margin : '0 5 0 0' 
    }
    ]
});


var toolPanel_1=Ext.create("Ext.panel.Panel", {
// hideen:false,
region : 'north',
dockedItems: [{
   xtype: 'toolbar',
   dock: 'top',
   id : "toolManage",
   layout: {
            type: 'vbox',
            align: 'right'
        },
   items: [ bPanel_1,tPanel_1 ]
}],
});


function doTopSearch_1(){
var searchKeyword = Ext.getCmp('keywordManage').getValue();
var searchTitle = Ext.getCmp('titleManage').getValue();
var searchContent = Ext.getCmp('contentManage').getValue();
var contentText = Ext.getCmp('contentTextManage').getValue();
if(searchKeyword == true){
knowStore_2.proxy.extraParams['workOrderTDTO.keyword'] = contentText;
}
if(searchTitle == true){
knowStore_2.proxy.extraParams['workOrderTDTO.title'] = contentText;
}
if(searchContent == true){
knowStore_2.proxy.extraParams['workOrderTDTO.content'] = contentText;
}
knowStore_2.load();
}


function initPanel() {
Ext.create("Ext.form.Panel", {
width : '100%',
height : '100%',
renderTo : Ext.getBody(),
layout : 'border',
items : [ toolPanel_1 ]
});
};


效果如下:



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值