87,921
社区成员
发帖
与我相关
我的任务
分享
//高级搜索弹出层
var Search_Window = new Ext.Window({
collapsible: true,
maximizable: true,
minWidth: 300,
minHeight: 180,
width:386,
height:250,
modal:true,
title:'高级搜索对话框',
closeAction:"hide",
layout: 'fit',
plain: true,
bodyStyle: 'padding:5px;',
buttonAlign: 'center',
items: Search_Panel,
buttons: [{
text: '提交',
handler:function(){
var IndustryNum=Search_Panel.getForm().findField('IndustryNum').getValue();
var UserName=Ext.getCmp("cbxj").getValue()
var RoleName=Search_Panel.getForm().findField('RoleName').getValue();
// var RoleName="";
var Sex=Search_Panel.getForm().findField('Sex').getValue();
var IP1=Search_Panel.getForm().findField('IP1').getValue();
var IP2=Search_Panel.getForm().findField('IP2').getValue();
jsonData= {operatype:'Express_find',IndustryNum:IndustryNum,UserName:UserName,RoleName:RoleName,Sex:Sex,IP1:IP1,IP2:IP2};
Search_Window.hide();
CodeOperaSearch('../../WebUI/UserManage/UserManage.aspx',jsonData);
store.reload();
grid.store.reload();
}
},{
text: '关闭',
handler:function(){Search_Window.hide();}
}]
});
//高级搜索后台程序
var CodeOperaSearch=function(u,p){
var conn=new Ext.data.Connection();
conn.request({
url:u,
params:p,
method:'post',
scope:this,
callback:function(options,success,response){
if(success){
//
//Ext.MessageBox.alert('Info',response.responseText);
//store:response.responseText;这里的response.responseText是我查询之后我想要的信息,但是页面上面
//不能重新加载我的数据源
store.reload();
grid.store.reload();
}
else{
Ext.MessageBox.alert("提示","所提交的操作失败!");
Ext.MessageBox.alert('Info',response.responseText);
}
}});};
7行: <link rel="stylesheet" type="text/css" href="../../ext-3.1.0/resources/css/ext-all.css" />
9行: <script type="text/javascript" src="../../ext-3.1.0/adapter/ext/ext-base.js"></script>
11行: <script type="text/javascript" src="../../ext-3.1.0/ext-all.js"></script>
1高级收索返回的数据结构应当和第一次加载时的数据结构相同,这样才能成功loadData();
2建议这样的操作可以直接把参数传给store,直接到后台去查
buttons: [{
text: '提交',
handler:function(){
var IndustryNum=Search_Panel.getForm().findField('IndustryNum').getValue();
var UserName=Ext.getCmp("cbxj").getValue()
var RoleName=Search_Panel.getForm().findField('RoleName').getValue();
// var RoleName="";
var Sex=Search_Panel.getForm().findField('Sex').getValue();
var IP1=Search_Panel.getForm().findField('IP1').getValue();
var IP2=Search_Panel.getForm().findField('IP2').getValue();
//这里拿到值没有这么麻烦
alert(Search_Panel.getForm().getValues() + "-" + Ext.encode(Search_Panel.getForm().getValues()));
alert(Search_Panel.getForm().getValues(true) + "-" + Ext.encode(Search_Panel.getForm().getValues(true)));//看看true、false的不同效果
jsonData= {operatype:'Express_find',IndustryNum:IndustryNum,UserName:UserName,RoleName:RoleName,Sex:Sex,IP1:IP1,IP2:IP2};
Search_Window.hide();
CodeOperaSearch('../../WebUI/UserManage/UserManage.aspx',jsonData);//这里的ajax方法可以忽略不用,直接用reload方法查询即可
grid.store.baseParams = jsonData;//添加查询参数
store.reload();
grid.store.reload();
//前提grid对象是你查询的grid,store能够正确拿到
}
}
哦,loadData( Object data, [Boolean append] ) 用这个load下本地数据源
请教下17楼的兄弟
我的这个地方
response.responseText
返回的是JSON
为什么还要在这个地方Ext.util.JSON.decode(response.responseText)下
//还有loadData()是重新加载store的数据源码?
store.loadData(Ext.util.JSON.decode(response.responseText));
switch (GetFormValue("operatype"))
{
case "AddUser":
userEnt.UserName = GetFormValue("UserName");
userEnt.IndustryNum = GetFormValue("IndustryNum");
userEnt.UserPwd = Utility.Utility.Md5Encrypt(GetFormValue("UserPwd"));
userEnt.Department = GetFormValue("Department");
userEnt.UserType = GetFormValue("UserType");
userEnt.Tel = GetFormValue("Tel");
userEnt.Sex = GetFormValue("Sex") == "1" ? "男" : "女";
userEnt.IP1 = GetFormValue("IP1");
userEnt.IP2 = GetFormValue("IP2");
userEnt.UserID = Guid.NewGuid().ToString();
try
{
new Business.User.UserInfo().Add(userEnt);
// Bind();
Response.Write("{success:true}");
}
catch { Response.Write("{failure:true}"); }
Response.End();
break;
case "Express_find":
//这个是查询搜索的
//如果请求的是用户名称的话所请求的值就是UserID,否则就是UserName
string Where="UserID="+"'"+GetFormValue("UserName")+"'";
UserName = GetFormValue("UserName").Length == 36 ? UserMethod.GetDataByOption("Users", Where).Rows[0]["UserName"].ToString() : GetFormValue("UserName");
IndustryNum = GetFormValue("IndustryNum");
Sex = GetFormValue("Sex") == "1" ? "男" : "女";
IP1 = GetFormValue("IP1");
IP2 = GetFormValue("IP2");
RoleName = GetFormValue("RoleName");
//这是经过查询过滤之后最后的结果,我刚才调试了的,确实是我要的结果
DataTable DT = UserMethod.GetUserByWhere(UserName, IndustryNum, Sex, IP1, IP2, RoleName);
Response.Write(JSONHelper.DataTable2Json(DT));
Response.Write("{success:true}");
Response.End();
break;