<script type="text/javascript" src="~/js/jquery-1.9.1.min.js"></script>
$(function () {
initData();
$('#btn').click(function () {
initData(InitQuery());
});
});
function initData(params) {
$('#tt').datagrid({
url: '/Admin/LuckRecord/GetRecordListByRecordName',
width: 900,
//height: 350,
title: '战绩榜列表',
//iconCls: 'icon-save',
fitColumns: true,
rownumbers: true, //是否加行号
pagination: true, //是否显式分页
pageSize: 10, //页容量,必须和pageList对应起来,否则会报错
pageNumber: 1, //默认显示第几页
autoRowHeight: true,//自适应高度
nowrap: false,// 如果为true,则在同一行中显示数据。设置为true可以提高加载性能。
pageList: [10, 20, 30],//分页中下拉选项的数值
columns: [[
{ field: 'Id', title: 'Id', width: 50 },
{ field: 'RecordName', title: 'Record名', width: 200 },
{
field: 'IsShow', title: '前台显示', formatter: function (value) {
if (value == 1) { return "显示"; }
else { return "不显示"; }
}, width: 50, align: 'center'
}
,
{
field: 'IsUsed', title: '审核状态', formatter: function (value) {
if (value == 1) { return "审核通过"; }
else if (value == 2) { return "审核未通过"; }
else { return "未审核"; }
}, width: 80, align: 'center'
},
{
field: 'InDateTime', title: '录入时间', width: 100, align: 'center'
, formatter: function (val, rec) {
return JsonDateFormatterWithTime(val);
}
},
{
field: '', title: '操作', align: 'center', width: 400, formatter: function (value, rowData, rowIndex) {
return '<a href="@Url.Action("LuckRecordEdit", "LuckRecord")?id=' + rowData.Id + '">编辑</a> <a href="javascript://" οnclick="Delete(' + rowData.Id + ')">删除</a>';
}
}
]],
toolbar: '#tb',//搜索div
queryParams: params //搜索json
});
}
function InitQuery() {
var queryParams = { RecordName: $("#txt").val() };
return queryParams;
}
function Delete(id) {
$.messager.defaults = { ok: "是", cancel: "否" };
$.messager.confirm("操作提示", "确认删除吗?", function (result) {
if (result) {
$.post("@Url.Action("LuckRecordDelete", "LuckRecord")", { id: id },
function (data) {
if (data.result == -1) {
$.messager.alert('Warning', data.msg, "warning");
} else {
$('#tt').datagrid("reload");
}
});
}
});
}