bootstrapTable 修改栏位值

来源:互联网 发布:手机淘宝怎么投诉商家 编辑:程序博客网 时间:2024/05/17 18:13
function initEnvironmentSensorTable() { //初始化EnvironmentSensor的bootstrap-table的表格
tableEnvironmentSensor = $('#environmentSensor_table').bootstrapTable({
method: 'get', //请求方式(*)
striped: true, //是否显示行间隔色
cache: false, //是否使用缓存,默认为true,所以一般情况下需要设置一下这个属性(*)
pagination: true, //是否显示分页(*)
sortable: false, //是否启用排序
sortOrder: "asc", //排序方式
sidePagination: "client", //分页方式:client客户端分页,server服务端分页(*)
pageNumber: 1, //初始化加载第一页,默认第一页
pageSize: 6, //每页的记录行数(*)
pageList: [10, 25, 50, 100], //可供选择的每页的行数(*)
clickToSelect: true,
showExport: true, //是否显示导出
singleSelect:true,
exportDataType: "basic", //basic', 'all', 'selected'.
columns: [
{
field : '',
title : '編號',
align:'center',
valign:'middle',
formatter : function(value, row, index) {
return index + 1;
}
}, 
{
checkbox: true
}, {
field: 'sensor_kind',
title: '傳感器種類',
align:'center',
valign:'middle',
}, {
field: 'sensor_Interface',
title: '接口類型',
align:'center',
valign:'middle',
sortable: true,

editable:{
type:'select',
title:'接口類型',
source:[{value:"IIC",text:"IIC"},{value:"UART",text:"UART"},{value:"1-Wire",text:"1-Wire"},{value:"SPI",text:"SPI"},{value:"Analog_Output",text:"Analog_Output"},{value:"Digital_Output",text:"Digital_Output"}],
validate: function (v) {
// alert(v);
var selectContent = table.bootstrapTable('getSelections')[0];
var objjson = JSON.parse(JSON.stringify(selectContent));
// alert(JSON.stringify(selectContent));
//alert(objjson.eb_Key +" "+objjson.board_Name+" "+objjson.org_Id+" "+objjson.memo);
if(typeof(selectContent) == 'undefined') { 
         alert("未選擇");
         return false;
       }else{
       if(window.confirm('确认修改?')){   
       $.ajax({
      type : "POST",
      url : "EnvironmentSensorModify",
      dataType : "json",
      data:{
      "sensor_KEY": objjson.sensor_KEY,
      "sensor_Interface": v,
      "Sensor_Supplier":objjson.sensor_Supplier,
      "Sensor_brand":objjson.sensor_brand,
      "sensor_kind":objjson.sensor_kind,
      "Sensor_tel":objjson.sensor_tel
      },
      success : function(msg) {                 
                    $("#prompt_message").css({"color":"green",'fontWeight':'bold'});
                    $("#prompt_message").text("SUCCESS:修改的Key是"+msg.environmentSensorModifyFlag);      
                    query();                      
                   clearInterval(inrobj);
                   inrobj=setInterval("clearMsg()",5000);      
      },
      error : function() {
        $("#prompt_message").css({"color":"red",'fontWeight':'bold'});
                  $("#prompt_message").text("错误:修改失败");                                          
                 clearInterval(inrobj);
                 inrobj=setInterval("clearMsg()",5000);
      }
      });          
              return true;       
       }else
       {
            window.location.Reload();
return false;
       }
       }
}},

}, {
field: 'sensor_brand',
title: '品牌型號',
align:'center',
valign:'middle',
sortable: true,
editable:{
type:'text',
title:'品牌型號',
//source:[{value:"IIC",text:"IIC"},{value:"UART",text:"UART"},{value:"1-Wire",text:"1-Wire"},{value:"SPI",text:"SPI"},{value:"Analog_Output",text:"Analog_Output"},{value:"Digital_Output",text:"Digital_Output"}],
validate: function (v) {
// alert(v);
var selectContent = table.bootstrapTable('getSelections')[0];
var objjson = JSON.parse(JSON.stringify(selectContent));
// alert(JSON.stringify(selectContent));
//alert(objjson.eb_Key +" "+objjson.board_Name+" "+objjson.org_Id+" "+objjson.memo);
if(typeof(selectContent) == 'undefined') { 
         alert("未選擇");
         return false;
       }else{
       if(window.confirm('确认修改?')){   
       $.ajax({
      type : "POST",
      url : "EnvironmentSensorModify",
      dataType : "json",
      data:{
      "sensor_KEY": objjson.sensor_KEY,
      "sensor_Interface": objjson.sensor_Interface,
      "Sensor_Supplier":objjson.sensor_Supplier,
      "Sensor_brand":v,
      "sensor_kind":objjson.sensor_kind,
      "Sensor_tel":objjson.sensor_tel
      },
      success : function(msg) {                 
                    $("#prompt_message").css({"color":"green",'fontWeight':'bold'});
                    $("#prompt_message").text("SUCCESS:修改的Key是"+msg.environmentSensorModifyFlag);      
                    query();                      
                   clearInterval(inrobj);
                   inrobj=setInterval("clearMsg()",5000);      
      },
      error : function() {
        $("#prompt_message").css({"color":"red",'fontWeight':'bold'});
                  $("#prompt_message").text("错误:修改失败");                                          
                 clearInterval(inrobj);
                 inrobj=setInterval("clearMsg()",5000);
      }
      });          
              return true;
       
       }else
       {
            window.location.Reload();
return false;
       }
       }
}},
} ,
{
field: 'sensor_Supplier',
title: '供應商',
align:'center',
valign:'middle',
sortable: true,
editable:{
type:'text',
title:'供應商',
//source:[{value:"IIC",text:"IIC"},{value:"UART",text:"UART"},{value:"1-Wire",text:"1-Wire"},{value:"SPI",text:"SPI"},{value:"Analog_Output",text:"Analog_Output"},{value:"Digital_Output",text:"Digital_Output"}],
validate: function (v) {
// alert(v);
var selectContent = table.bootstrapTable('getSelections')[0];
var objjson = JSON.parse(JSON.stringify(selectContent));
// alert(JSON.stringify(selectContent));
//alert(objjson.eb_Key +" "+objjson.board_Name+" "+objjson.org_Id+" "+objjson.memo);
if(typeof(selectContent) == 'undefined') { 
         alert("未選擇");
         return false;
       }else{
       if(window.confirm('确认修改?')){   
       $.ajax({
      type : "POST",
      url : "EnvironmentSensorModify",
      dataType : "json",
      data:{
      "sensor_KEY": objjson.sensor_KEY,
      "sensor_Interface":objjson.sensor_Interface,
      "Sensor_Supplier":v,
      "Sensor_brand":objjson.sensor_brand,
      "sensor_kind":objjson.sensor_kind,
      "Sensor_tel":objjson.sensor_tel
      },
      success : function(msg) {                 
                    $("#prompt_message").css({"color":"green",'fontWeight':'bold'});
                    $("#prompt_message").text("SUCCESS:修改的Key是"+msg.environmentSensorModifyFlag);      
                    query();                      
                   clearInterval(inrobj);
                   inrobj=setInterval("clearMsg()",5000);      
      },
      error : function() {
        $("#prompt_message").css({"color":"red",'fontWeight':'bold'});
                  $("#prompt_message").text("错误:修改失败");                                          
                 clearInterval(inrobj);
                 inrobj=setInterval("clearMsg()",5000);
      }
      });          
              return true;
       
       }else
       {
            window.location.Reload();
return false;
       }
       }
}},
} ,
{
field: 'sensor_tel',
title: '供應商電話',
align:'center',
valign:'middle',
sortable: true,
editable:{
type:'text',
title:'供應商電話',
//source:[{value:"IIC",text:"IIC"},{value:"UART",text:"UART"},{value:"1-Wire",text:"1-Wire"},{value:"SPI",text:"SPI"},{value:"Analog_Output",text:"Analog_Output"},{value:"Digital_Output",text:"Digital_Output"}],
validate: function (v) {
// alert(v);
var selectContent = table.bootstrapTable('getSelections')[0];
var objjson = JSON.parse(JSON.stringify(selectContent));
// alert(JSON.stringify(selectContent));
//alert(objjson.eb_Key +" "+objjson.board_Name+" "+objjson.org_Id+" "+objjson.memo);
if(typeof(selectContent) == 'undefined') { 
         alert("未選擇");
         return false;
       }else{
       if(window.confirm('确认修改?')){   
       $.ajax({
      type : "POST",
      url : "EnvironmentSensorModify",
      dataType : "json",
      data:{
      "sensor_KEY": objjson.sensor_KEY,
      "sensor_Interface": objjson.sensor_Interface,
      "Sensor_Supplier":objjson.sensor_Supplier,
      "Sensor_brand":objjson.sensor_brand,
      "sensor_kind":objjson.sensor_kind,
      "Sensor_tel":v
      },
      success : function(msg) {                 
                    $("#prompt_message").css({"color":"green",'fontWeight':'bold'});
                    $("#prompt_message").text("SUCCESS:修改的Key是"+msg.environmentSensorModifyFlag);      
                    query();                      
                   clearInterval(inrobj);
                   inrobj=setInterval("clearMsg()",5000);      
      },
      error : function() {
        $("#prompt_message").css({"color":"red",'fontWeight':'bold'});
                  $("#prompt_message").text("错误:修改失败");                                          
                 clearInterval(inrobj);
                 inrobj=setInterval("clearMsg()",5000);
      }
      });          
              return true;       
       }else
       {
            window.location.Reload();
return false;
       }
       }
}},
}
],
formatLoadingMessage: function(){
    return "";
  },
  onCheck:function(row){//选择table某一行 
  var selectContent = tableEnvironmentSensor.bootstrapTable('getSelections')[0];
  var objjson = JSON.parse(JSON.stringify(selectContent));
//alert(objjson.sensor_KEY+" "+objjson.sensor_Interface+" "+objjson.sensor_Supplier+" "+objjson.sensor_brand+" "+objjson.sensor_kind+" "+objjson.sensor_tel);
  $("#EnvironmentSensorClear").attr("disabled","disabled");//清除无效
  $("#EnvironmentSensorAdd").attr("disabled","disabled");//增加无效
  $("#EnvironmentSensorChange").removeAttr("disabled");//修改有效
  $("#EnvironmentSensorInvalid").removeAttr("disabled");//失效有效
  $("#EnvironmentSensorSave").removeAttr("disabled");//保存有效
  EnvironmentSensorInputDisabled();//输入无效    
  $("#selectSensor_kind").val(objjson.sensor_kind);
  $("#selectSensor_Interface").val(objjson.sensor_Interface);
  $("#Sensor_brand").val(objjson.sensor_brand);
  $("#Sensor_Supplier").val(objjson.sensor_Supplier);
  $("#Sensor_tel").val(objjson.sensor_tel);
  $("#sensor_KEY").val(objjson.sensor_KEY);
  $("#environmentSensor_valid_Flag").val(objjson.environmentSensor_valid_Flag);
  },
  onUncheck:function(row){
  initformEnrionmentSensor();
  },
});
};
原创粉丝点击