资源描述
学习文件.docx
《学习文件.docx》由会员分享,可在线阅读,更多相关《学习文件.docx(8页珍藏版)》请在冰豆网上搜索。
学习文件
一、异步请求弹出窗口:
varkeyword="";
functionrefreshGrid(){
$("#list").jqGrid('setGridParam',{
url:
"v/pub/knowledge!
getKnowledgeList",
postData:
{'keyword':
keyword}
}).trigger("reloadGrid");
}
$(function(){
$.ajaxSetup({
cache:
false//关闭AJAX相应的缓存
});
//列表加载
$("#list").jqGrid({
url:
'v/pub/knowledge!
getKnowledgeList',
postData:
{'keyword':
keyword},
datatype:
"xml",
colNames:
['编号','标题','关键字','创建日期','修改日期'],
colModel:
[{name:
'sid',index:
'sid',width:
90},
{name:
'title',index:
'title',width:
90},
{name:
'keyword',index:
'keyword',width:
100},
{name:
'mkDate',index:
'mkDate',width:
100},
{name:
'upDate',index:
'upDate',width:
100}],
rowNum:
10,
width:
850,
rowList:
[5,10,15,20],
autowidth:
true,
height:
400,
pager:
$("#pager"),
sortname:
'name',
sortorder:
'asc',
gridview:
true,
viewrecords:
true,
multiselect:
true
}).navGrid('#pager',{edit:
false,add:
false,del:
false,search:
false});
//添加按钮执行
$("#add").click(function(ev){
ev.preventDefault();
$("body").append("
");
$("#dialog-add-knowledge").dialog({
autoOpen:
false,
height:
300,
width:
300,
modal:
true,
draggable:
false,
resizable:
false,
title:
'添加知识库分类信息',
buttons:
{
"确定":
function(){
vartitle=$("#title"),
keyword=$("#keyword"),
allFields=$([]).add(title).add(keyword);
allFields.removeClass("ui-state-error");
if(!
checkRequired(title.val())){
//设置错误样式
title.addClass("ui-state-error");
//设置错误提示
alert("不能为空");
return;
}
$("#formPost").submit();
},
"取消":
function(){
$(this).dialog("close");
}
},
close:
function(){
$("#dialog-add-knowledge").empty();
$("#dialog-add-knowledge").remove();
}
}).load("v/pub/knowledge!
addDialog?
dt=s",function(){
//加载窗口,并初始化表单
$('#formPost').ajaxForm({
success:
function(msg){
if(msg=="SUCCESS"){
alert("添加成功");
$("#dialog-add-knowledge").dialog("close");
$("#list").jqGrid().trigger("reloadGrid");
}
else{
alert("添加失败:
"+msg);
$("#dialog-add-knowledge").dialog("close");
}
}
});
$("#dialog-add-knowledge").dialog("open");
});
});
//删除按钮执行
$("#remove").click(function(ev){
ev.preventDefault();
varsels=$("#list").jqGrid('getGridParam','selarrrow');
if(sels==""){
alert('请选择要删除的项!
');
return;
}
if(!
confirm("确定删除选择的客户信息吗?
")){
return;
}
$.ajax({
type:
"POST",
url:
"v/pub/knowledge!
remove",
data:
"sid="+sels,
beforeSend:
function(){
},
error:
function(){
alert("请求失败...");
},
success:
function(msg){
if(msg=="SUCCESS"){
alert("已成功删除!
");
$("#list").jqGrid().trigger("reloadGrid");
}else{
alert("删除失败:
"+msg);
}
}
});
});
//更改按钮执行
$("#update").click(function(ev){
ev.preventDefault();
varsels=$("#list").jqGrid('getGridParam','selarrrow');
if(sels==""){
alert('请选择要更改的项!
');
return;
}
if(sels.length>1){
alert('更改时,只能选择一项!
');
return;
}
$("body").append("
");