TopJUI是对EasyUI的封装,本质其实是一样的,本文以TopJUI为例,有问题可以下方留言,看到会回复,一起学习,共同进步。话不多说,直接源码。
1.静态页面,datagrid是动态创建的
var url = '@Url.Action("LoadPlanInspectionListQuestionDatagridInfo", "Inspection")';
$("#PlanInspectionQuestionListInfo").iDatagrid({
fit: true,
fitColumns: true,
method: 'GET',
url: url,
queryParams: {
planid:@ViewBag.planid,
usernumber: huserid
},
nowrap: false,
emptyMsg: '没有数据',
singleSelect: true,
rownumbers: false, //是否加行号
pagination: false, //是否显式分页
rowStyler: function (index, row) {
if (row.status == 0) {
return 'color:red;';
}
},
columns: [
[
{ field: "deptname", title: "部门", rowspan: 2, align: "center", width: 100 },
{ field: "inspectionplace", title: "地址", rowspan: 2, align: "center", width: 100 },
{ field: "insertdate", title: "时间", rowspan: 2, align: "center", width: 100 },
{ title: "问题", colspan: 2, align: "center", width: 100 },
{ title: "回复", colspan: 2, align: "center", width: 100 },
{
field: "status", title: "状态", rowspan: 2, align: "center", width: 100,
formatter: function (value, row, index) {
if (value == 0) {
return '待解决';
} else if (value == 1) {
return '已解决';
}
}
},
{ field: "operate", title: "操作", rowspan: 2, width: 100, formatter: operateFormatter},
],
[
{ field: "question", title: "描述", rowspan: 1, align: "center", width: 100 },
{ field: "planinspectionquestionimg", title: "图片", rowspan: 1, align: "center", width: 100, formatter: questionImageFormatter},
{ field: "planinspectionfeedback", title: "描述", rowspan: 1, align: "center", width: 100, formatter: questionImageFormatter},
{ field: "planinspectionfeedbackimg", title: "图片", rowspan: 1, align: "center", width: 100, formatter: questionImageFormatter},
]
],
**onLoadSuccess: function () {
$('.image-list').on('click', '.cover', function () {
var this_ = $(this);
var images = this_.parents('.image-list').find('.cover');
var imagesArr = new Array();
$.each(images, function (i, image) {
imagesArr.push($(image).children('img').attr('src'));
});
$.pictureViewer({
images: imagesArr, //需要查看的图片,数据类型为数组
initImageIndex: this_.index() + 1, //初始查看第几张图片,默认1
scrollSwitch: true //是否使用鼠标滚轮切换图片,默认false
});
});
}**
});
function questionImageFormatter(value, row, index) {
var htmlstr;
htmlstr = '';
for (var i = 0; i < row.planinspectionquestionimg.length; i++) {
if (i == 0) {
htmlstr += "";
htmlstr += '';
htmlstr += '';
} else {
htmlstr += "";
htmlstr += '';
htmlstr += '';
}
}
htmlstr += '';
return htmlstr;
}