datagrid columns

columns: [[
{ field: 'Source_Id', title: 'Source_Id', hidden: true },
//{ field: 'Current_Value', hidden: true },
{ field: 'Source_Type_Id', title: 'Source_Type_Id', hidden: true },
{
//field: 'Object_Name', title: SIMS_lang.ColumnsField.Signal, width: 300, editor: {
field: 'Object_Id', title: SIMS_lang.ColumnsField.Signal, width: 300, editor: {
//field: 'station_type_name', title: SIMS_lang.ColumnsField.Signal, width: 300, editor: {
type: 'combotree',
options: {
data: treeData,
onBeforeSelect: function (node) {
var ed = $("#divELlink" + pNo).datagrid('getEditors', clickIndex);
if (node.attributes.Object_Type_Id == 3) {
$.messager.show({
title: SIMS_lang.DialogTitle.Prompt,
msg: SIMS_lang.MessageStr.PleaseSelectMeasure,
timeout: 3000,
showType: 'slide'
});
if (ed && ed.length != 0) {
$(ed[1].target).combobox('disable');
$(ed[2].target).combobox('disable');
}
return false;
}
return true;
},
onSelect: function (node) {
comData = "";
var ed = $("#divELlink" + pNo).datagrid('getEditors', clickIndex);
if (node.attributes.Object_Type_Id == 3) {
$.messager.show({
title: SIMS_lang.DialogTitle.Prompt,
msg: SIMS_lang.MessageStr.PleaseSelectMeasure,
timeout: 3000,
showType: 'slide'
});
if (ed && ed.length != 0) {
$(ed[1].target).combobox('disable');
$(ed[2].target).combobox('disable');
}
return;
}
else {
if (ed && ed.length != 0) {
$(ed[1].target).combobox('enable');
$(ed[2].target).combobox('enable');
}
}
if (node.attributes.Object_Type_Id == 4) {
$.ajax({
type: "post",
url: "/RealTimeMonitor/GetEventLinkage",
data: { objectid: node.id, queryType: 5 },
success: function (data) {
$(ed[1].target).combobox({
valueField: 'id',
textField: 'name',
data: data,
onLoadSuccess: function () {
if (tempSourceValue != null) {
$(ed[1].target).combobox('select', tempSourceValue);
tempSourceValue = null;
}
else {
if (data.length > 0) {
$(ed[1].target).combobox('select', data[0].id);
}
}
}
});
comData = data;
}
});
$(ed[2].target).combobox({
valueField: 'id',
textField: 'name',
data: [{ id: '0', name: '0' }]
});
$(ed[2].target).combobox('select', 0);
$(ed[2].target).combobox('disable');
}
else {
$(ed[1].target).combobox('clear');
$(ed[1].target).combobox({
valueField: 'id',
textField: 'name',
data: [{ id: '', name: '' }]
});
$(ed[2].target).combobox('enable');
}
var nn = $(ed[0].target).combotree('tree').tree('getSelected');
if (nn) {
$(ed[0].target).combotree('tree').tree('expandTo', nn.target);
}
}
}
},
formatter: function (value, row, index) {
if (value != "") {
for (var i = 0; i < treeData.length; i++) {
if (value == treeData[i].id) {
row.Source_Id = value;
row.Source_Type_Id = treeData[i].attributes.Object_Type_Id;
return treeData[i].text;
}
var child = treeData[i].children;
for (var j = 0; j < child.length; j++) {
if (value == child[j].id) {
row.Source_Id = value;
row.Source_Type_Id = child[j].attributes.Object_Type_Id;
return child[j].text;
}
}
}
}
return value;
}
},
{ field: 'Source_Value_Low', title: SIMS_lang.ColumnsField.ContorlValue, hidden: true },
{
//field: 'Source_Value_Low', title: SIMS_lang.ColumnsField.ValueLowLimit, width: 200, editor: { type: 'combobox', options: { width: 200 } },
field: 'Contrl_means', title: SIMS_lang.ColumnsField.ValueLowLimit, width: 200, editor: {
type: 'combobox', options: {
width: 200
}
},
formatter: function (value, row, index) {
if (comData != "" && comData.length != 0) {
for (var i = 0; i < comData.length; i++) {
//if (value == comData[i].State_Value) {
// row.Source_Value_Low = value;
// return comData[i].State_Means;
//}
if (value == comData[i].id) {
row.Source_Value_Low = value;
return comData[i].name;
}
}
} else {
//if (value.length>0) {
// var alarmValue = parseInt(row.Current_Value).toString();
// var s = value.replace(/{/g, '').replace(/}/g, '').replace(/"/g, '');
// arrayObj = new Array();
// arrayObj2 = new Array();
// arrayObj = s.split(',');
// for (var i = 0; i < arrayObj.length; i++) {
// arrayObj2 = arrayObj[i].split(':');
// if (arrayObj2[0] == alarmValue) {
// return arrayObj2[1];
// }
// }
//}
//else {
return value;
//}
}
}
},
{
field: 'Source_Value_High', title: SIMS_lang.ColumnsField.ValueHighLimit, width: 200, editor: { type: 'combobox', options: { width: 200 } }
}
]]

posted @ 2016-09-26 09:32  芜明-追星  阅读(663)  评论(0编辑  收藏  举报