js 具体代码如下 求大牛解答
(function($){
$.fn.data = function(options){
$.ajax({
//请求方式为get
type: "GET",
//xml文件位置
url: "data.xml",
async: false,
//返回数据格式为xml
dataType: "xml",
//请求成功完成后要执行的方法
success: function (data) {
$(data).find('aaaa').each(function (i) { //读取xml文件,获取默认参数
//alert(12);
var $item = $(this);
pagin = $item.find('pagination').text();
pageL = $item.find('pageList').text();
rownu = $item.find('rownumbers').text();
pageS = $item.find('pageSize').text();
checkOnSelect = $item.find('checkOnSelect').text();
//alert(checkOnSelect);
text = $item.find('text').text();
})
}
});
$('#db').datagrid({
idField:'itemid', //标识字段
title:'数据列表',
width:500,
//height:300,
url:'datagrid_data1.json',
fitColumns:true, //自适应窗口
nowrap:true, //不显示在一行
striped:true, //各行换色
loadMsg:'数据加载中,请稍等...', //加载数据时提示的信息
rownumbers:rownu,
//singleSelect:true,
checkOnSelect:true, //点击行时复选框是否被选中
sortName:'sendTime',
sortOrder:'desc',
remoteSort:false,
//scrollbarSize:200,
rowStyler:function(index,data){
//console.info(index);
//console.info(data);
if(data.isGet==0){
//return 'background:silver';
}else{
//return 'background:green';
}
},
columns:[[
{checkbox:true},
{field:'ck',title:'接收人',width:100},
{field:'productid',title:'内容',width:100},
{field:'listprice',title:'发送时间',width:100},
{field:'unitcost',tile:'cjkcs',width:100},
{field:'attr1',tile:'cjkcs',width:100},
{field:'status',tile:'cjkcs',width:100},
]],
pagination:pagin,
pageSize:pageS,
pageList:pageL,
toolbar:[
{text:'增加',iconCls:'icon-add',handler:function(){
//alert('ok');
$("#register").dialog('open');
}},
{ text:'删除',
iconCls:'icon-remove',
handler:function(){
var selects = $("#data").datagrid("getSelections");
//alert(selects.length);
if(selects.length<=0){
$.messager.show({
title:'温馨提示',
msg:'请选择要删除的记录'
});
}else{
//将选中的记录删除(先找到每一个选中的元素)
for(var i=0;i<selects.length;i++){
//alert(selects[i].messID);
$.post("delete.php","id="+selects[i].messID,function(r){
//alert('ok');
$("#data").datagrid("reload");
})
}
}
}
},
{text:'编辑',iconCls:'icon-edit'},
{text:'查询',iconCls:'icon-search'},
],
});
}
}
)(jQuery);
xml 如下
<?xml version="1.0" encoding="utf-8"?>
false
[1,2,3]
true
5
true
1//默认是有,如果是0则关闭