bind: function (winSize) {
var text = parent.$('#tree_struct').tree('getSelected');
var pid = parent.$('#tree_struct').tree('getParent', text.target);
var part = parent.$('#tree_struct').tree('getParent', pid.target);
var s = pid.text.indexOf('|');
var p = part.text.indexOf('|');
$('#list').datagrid({
url: actionURL + "?elementid=" + $('#hideElementId').val() + '&bid=' + parent.$('#hideBridgeId').val() + '&struct=' + escape(pid.text.substr(0, s)) + '&part=' + escape(part.text.substr(0, p)),
toolbar: '#toolbar',
title: "构件病害列表",
iconCls: 'icon icon-list',
width: winSize.width,
height: winSize.height,
nowrap: false, //折行
rownumbers: true, //行号
striped: true, //隔行变色
idField: 'KeyId', //主键
singleSelect: true, //单选
frozenColumns: [[]],
columns: [[
{
title: '损害类型', field: 'Defect_des', width: 200, formatter: function (value, row, index) {
return '<a href="#" style="color:green;" οnclick="CRUD.viewDefect(\'' + row.DefectTypeID + '\')">' + value + '</a>';
}
},
{ title: '损害数量', field: 'count_n', width: 100 },
{
title: '程度', field: 'DefectGradeDes', width: 100, formatter: function (value, row, index) {
for (var i = 0; i < defectLV.length; i++) {
if (defectLV[i].text == value) return defectLV[i].text;
}
return value;
},
editor: {
type: 'combobox',
options: {
data: defectLV,
valueField: 'id',
textField: 'text',
required: true
}
}
},
{
title: '扣分值DP', field: 'DP', width: 100
},
{
title: 'Wij', field: 'wly', width: 100, formatter: function (value, row, index) {
var newvalue = Math.round(value * 1000) / 1000;
return newvalue;
}
},
{
title: 'Uij', field: 'U', width: 100, formatter: function (value, row, index) {
var newvalue = Math.round(value * 1000) / 1000;
return newvalue;
}
}
]],
pagination: true,
pageSize: PAGESIZE,
pageList: [20, 40, 50],
onBeforeLoad: function () {
$(this).datagrid('rejectChanges');
},
//onLoadSuccess: function (data) {
// var rownum=$('#list').datagrid('getRows').length;
//此处用于使单元格在加载完毕后就处于可编辑状态
// for (var i = 0; i < rownum; i++) {
//$('#list').datagrid('beginEdit', i);
//}
//},
onClickRow: function (rowIndex, row) {
$.ajax({
url: actionURL + '?' + createParam('assLevel', row.DefectTypeID),
type: 'post',
async:false,
success: function (d) {
if (d) {
defectLV = eval(d);
}
}
})
if (lastIndex != -1) {
$('#list').datagrid('endEdit', lastIndex);
}
$('#list').datagrid('beginEdit', rowIndex);
lastIndex = rowIndex;
var ed = $('#list').datagrid('getEditor', { index: rowIndex, field: "DefectGradeDes" });
$(ed.target).combobox({
data: defectLV,
valueField: 'id',
textField: 'text',
required: true,
width:100
});
},
onBeforeEdit: function (rowIndex, row) {
row.editing = true;
//var value = $(ed.target).combobox('getValue');
},
onAfterEdit: function (index, row) {
row.editing = false;
$('#list').datagrid('refreshRow', index);
var query = createParam('edit', row.KeyId);
var hUrl = actionURL + '?asslevel=' + escape(row.DefectGradeDes) + '&bid=' + parent.$('#hideBridgeId').val();
jQuery.ajaxjson(hUrl, query, function (d) {
if (parseInt(d) > 0) {
msg.ok('修改成功!');
grid.reload();
} else {
MessageOrRedirect(d);
}
});
}
});
},
getSelectedRow: function () {
return $('#list').datagrid('getSelected');
},
reload: function () {
$('#list').datagrid('clearSelections').datagrid('reload', { filter: '' });
}
var text = parent.$('#tree_struct').tree('getSelected');
var pid = parent.$('#tree_struct').tree('getParent', text.target);
var part = parent.$('#tree_struct').tree('getParent', pid.target);
var s = pid.text.indexOf('|');
var p = part.text.indexOf('|');
$('#list').datagrid({
url: actionURL + "?elementid=" + $('#hideElementId').val() + '&bid=' + parent.$('#hideBridgeId').val() + '&struct=' + escape(pid.text.substr(0, s)) + '&part=' + escape(part.text.substr(0, p)),
toolbar: '#toolbar',
title: "构件病害列表",
iconCls: 'icon icon-list',
width: winSize.width,
height: winSize.height,
nowrap: false, //折行
rownumbers: true, //行号
striped: true, //隔行变色
idField: 'KeyId', //主键
singleSelect: true, //单选
frozenColumns: [[]],
columns: [[
{
title: '损害类型', field: 'Defect_des', width: 200, formatter: function (value, row, index) {
return '<a href="#" style="color:green;" οnclick="CRUD.viewDefect(\'' + row.DefectTypeID + '\')">' + value + '</a>';
}
},
{ title: '损害数量', field: 'count_n', width: 100 },
{
title: '程度', field: 'DefectGradeDes', width: 100, formatter: function (value, row, index) {
for (var i = 0; i < defectLV.length; i++) {
if (defectLV[i].text == value) return defectLV[i].text;
}
return value;
},
editor: {
type: 'combobox',
options: {
data: defectLV,
valueField: 'id',
textField: 'text',
required: true
}
}
},
{
title: '扣分值DP', field: 'DP', width: 100
},
{
title: 'Wij', field: 'wly', width: 100, formatter: function (value, row, index) {
var newvalue = Math.round(value * 1000) / 1000;
return newvalue;
}
},
{
title: 'Uij', field: 'U', width: 100, formatter: function (value, row, index) {
var newvalue = Math.round(value * 1000) / 1000;
return newvalue;
}
}
]],
pagination: true,
pageSize: PAGESIZE,
pageList: [20, 40, 50],
onBeforeLoad: function () {
$(this).datagrid('rejectChanges');
},
//onLoadSuccess: function (data) {
// var rownum=$('#list').datagrid('getRows').length;
//此处用于使单元格在加载完毕后就处于可编辑状态
// for (var i = 0; i < rownum; i++) {
//$('#list').datagrid('beginEdit', i);
//}
//},
onClickRow: function (rowIndex, row) {
$.ajax({
url: actionURL + '?' + createParam('assLevel', row.DefectTypeID),
type: 'post',
async:false,
success: function (d) {
if (d) {
defectLV = eval(d);
}
}
})
if (lastIndex != -1) {
$('#list').datagrid('endEdit', lastIndex);
}
$('#list').datagrid('beginEdit', rowIndex);
lastIndex = rowIndex;
var ed = $('#list').datagrid('getEditor', { index: rowIndex, field: "DefectGradeDes" });
$(ed.target).combobox({
data: defectLV,
valueField: 'id',
textField: 'text',
required: true,
width:100
});
},
onBeforeEdit: function (rowIndex, row) {
row.editing = true;
//var value = $(ed.target).combobox('getValue');
},
onAfterEdit: function (index, row) {
row.editing = false;
$('#list').datagrid('refreshRow', index);
var query = createParam('edit', row.KeyId);
var hUrl = actionURL + '?asslevel=' + escape(row.DefectGradeDes) + '&bid=' + parent.$('#hideBridgeId').val();
jQuery.ajaxjson(hUrl, query, function (d) {
if (parseInt(d) > 0) {
msg.ok('修改成功!');
grid.reload();
} else {
MessageOrRedirect(d);
}
});
}
});
},
getSelectedRow: function () {
return $('#list').datagrid('getSelected');
},
reload: function () {
$('#list').datagrid('clearSelections').datagrid('reload', { filter: '' });
}