我不知道如何解释,以下代码有效
function DrawIrregularChartGrid() {
$('#data_grid').datagrid({
columns: [[{"field":"MeterID","title":"MeterID"},{"field":"ADateTime","title":"ADateTime"}]]
});
}
但这一个不起作用,没有错误消息,网格正在加载但列名称为空。
function DrawIrregularChartGrid() {
$('#data_grid').datagrid({
columns: [GetGridColumnNames()]
});
}
GetGridColumnNames()
返回
[{"field":"MeterID","title":"MeterID"},{"field":"ADateTime","title":"ADateTime"}]
GetGridColumnNames 函数
function GetGridColumnNames() {
var cols = [];
var IrregularChartParams = InitializeChartParams();
// parametreleri json stringe cevir...
var chartParams = JSON.stringify(IrregularChartParams);
$.ajax({
type: "POST",
url: app_base_url + 'Graph/GetGridColumnNames',
contentType: 'application/json; charset=utf-8',
data: chartParams,
success: function (result) {
$.each(result, function (index, value) {
cols.push(result);
});
},
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.status);
alert(thrownError);
},
beforeSend: function () {
},
complete: function () {
}
});
return cols;
}
dataGrid 列属性类型是对象数组。如何将GetGridColumnNames
返回对象分配给columns
属性。