首页 > 代码库 > easyui datagrid 动态表头2

easyui datagrid 动态表头2

前端

function goqry() {
$("#form").form("submit", {
url: "CJCK_bjcjfx_yfsl.aspx?opt=qry",
onSubmit: function () {
if ($(this).form(‘validate‘)) {
$(‘#tt‘).datagrid("loading");
return true;
} else {
return false;
}
},
success: function (data) {
data = http://www.mamicode.com/jQuery.parseJSON(data);
if (data.columns != undefined) {
if (data.columns.length == 4) {
if (data.total > 0) {
var frozenColumns = $(‘#tt‘).datagrid("options").frozenColumns;
for (var i = 0; i < frozenColumns[0].length; i++) {
frozenColumns[0][i].rowspan = 4;
}
}

} else if (data.columns.length == 3) {
if (data.total > 0) {
var frozenColumns = $(‘#tt‘).datagrid("options").frozenColumns;
for (var i = 0; i < frozenColumns[0].length; i++) {
frozenColumns[0][i].rowspan = 3;
}
}

}
if (data.columns != null) {
$(‘#tt‘).datagrid({
columns: data.columns,
data: data.rows
});
} else {
$(‘#tt‘).datagrid({
data: data.rows
});
}

} else {
$(‘#tt‘).datagrid({
data: data.rows,
columns:[[]]
});
}
$(‘#tt‘).datagrid("loaded");
}
});
}

后台代码

response.write(xx());

public string xx(){

EasyUIDatagrid data = http://www.mamicode.com/new EasyUIDatagrid();
data.total = dt.Rows.Count;
data.rows = DataTableToobject(dt);
data.columns = head;
return ToJson(data);

}

public class EasyUIDatagrid
{
public int total;
public object[] rows;
public object[] footer;
public string topmsg;
public EasyUIDatagridHead[][] columns;
public EasyUIMergeCells[] mergeCells;
}

 

easyui datagrid 动态表头2