如果传递的是json格式数据,记得将json数组转换成对象,如:
$(function(){
setData();
$.ajax({
async : false,
type : "post",
url : "./draftServlet",
data : {
"optionType" : "getColumnStruct"
},
dataType : "text",
success : function(data) {
var obj= data.split("?");
alert(obj[0]);
initDetail(obj);
}
});
});
function initDetail(columnStruct){
$("#tab").datagrid({
url:"./draftServlet",
singleSelect:true,
fit:true,
strped:true,
queryParams : {
"optionType" : "getDetailDate",
"G_MID" : $("#G_ID").val()
},
frozenColumns:[[
{field:'rownum',title:'行号',align:'center',width:50,
formatter: function(value,row,index){
return "<input type=\"text\" class=\"data_right\" value=\""+value+"\" style=\"width:"+(this.width-10)+"px;\">";
}},
{field:'tobacco_origin',title:'烟叶产地组',align:'center',width:100,
formatter: function(value,row,index){
return "<input type=\"text\" class=\"data_left\" value=\""+value+"\" style=\"width:"+(this.width)+"px;\">";
}},
{field:'tobacco_grade',title:'烟叶大等级',align:'center',width:100,
formatter: function(value,row,index){
return "<input type=\"text\" class=\"data_left\" value=\""+value+"\" style=\"width:"+(this.width)+"px;\">";
}},
{field:'tobacco_postion',title:'烟叶部位',align:'center',width:100,
formatter: function(value,row,index){
return "<input type=\"text\" class=\"data_left\" value=\""+value+"\" style=\"width:"+(this.width)+"px;\">";
}},
{field:'measure_unit',title:'计量单位',align:'center',width:100},
{field:'purchase_qty',title:'采购需求量',align:'center',width:100,
formatter: function(value,row,index){
return "<input type=\"text\" class=\"data_right\" value=\""+value+"\" style=\"width:"+(this.width-10)+"px;\">";
}},
{field:'draft_qty',title:'草案需求量',align:'center',width:100,
formatter: function(value,row,index){
return "<input type=\"text\" class=\"data_right\" value=\""+value+"\" style=\"width:"+(this.width-10)+"px;\">";
}}
]],
columns:eval(columnStruct[0]),//[[{field:'yuxi_company',title:'云南玉溪商业公司',align:'center',width:120,formatter: function(value,row,index){return "<input type=\"text\" class=\"data_right\" value=\""+value+"\" style=\"width:\"+(this.width-10)+\"px;\">";}},{field:'kunming_company',title:'云南昆明商业公司',align:'center',width:120,formatter: function(value,row,index){return "<input type=\"text\" class=\"data_right\" value=\""+value+"\" style=\"width:\"+(this.width-10)+\"px;\">";}}]],
onLoadSuccess: function(){
$(this).datagrid('freezeRow',0);
//合并单元格
$("#tab").datagrid('mergeCells',{
index:0,
field:'tobacco_origin',
colspan:4
});
}
});
}