i give the second datasource to the grid ,data has show , but the columns no change
i do like this :
if (sjlx.value() == "t_ori_last") {
$("#grid").kendoGrid({
dataSource: {
transport: {
read: {
type: "POST",
url: "../Handler/Handler_SJGL.ashx",
dataType: "json",
data: {
Ptype: "apmreal",
Pkeyword: $("#txt_keyword").val(),
Pcounty: countyid,
Psjlx: sjlx.value()
}
}
},
schema: {
model: {
fields: {
STATIONCODE: { type: "string" },
RECEIVETIME: { type: "string" },
PM25: { type: "number" },
PM10: { type: "number" },
PM05N: { type: "number" },
PM1N: { type: "number" },
PM25N: { type: "number" },
PM10N: { type: "number" },
TEMPERATURE: { type: "number" },
HUMIDITY: { type: "number" }
}
}
},
serverPaging: false,
batch: true,
pageSize: 25
},
height: ($(window).height() - 40),
sortable: true,
reorderable: true,
resizable: true,
filterable: true,
columnMenu: true,
//toolbar: [
// {
// name: "create",
// text: "新增用户"
// }
//],
pageable: {
pageSizes: true,
buttonCount: 5,
input: true,
refresh: true,// 是否允许刷新页面
numeric: false
},
change: function (e) {
$("#grid").data("kendoGrid").dataSource.read();
$("#grid").data("kendoGrid").refresh();
},
columns: [{
field: "STATIONCODE",
title: "编号",
width: 200
},
{
field: "RECEIVETIME",
title: "时间"
},
{
field: "PM25",
title: "PM25"
},
{
field: "PM10",
title: "PM10"
},
{
field: "PM05N",
title: "PM05数量"
},
{
field: "PM1N",
title: "PM1数量"
},
{
field: "PM25N",
title: "PM2.5数量"
},
{
field: "PM10N",
title: "PM10数量"
},
{
field: "TEMPERATURE",
title: "温度"
},
{
field: "HUMIDITY",
title: "湿度"
}]
});
}
else {
$("#grid").kendoGrid({
dataSource: {
transport: {
read: {
type: "POST",
url: "../Handler/Handler_SJGL.ashx",
dataType: "json",
data: {
Ptype: "apmreal",
Pkeyword: $("#txt_keyword").val(),
Pcounty: countyid,
Psjlx: sjlx.value()
}
}
},
schema: {
model: {
fields: {
STATIONCODE: { type: "string" },
RECEIVETIME: { type: "string" },
PM25: { type: "number" },
PM10: { type: "number" },
TEMPERATURE: { type: "number" },
HUMIDITY: { type: "number" }
}
}
},
serverPaging: false,
pageSize: 25
},
height: ($(window).height() - 40),
sortable: true,
reorderable: true,
resizable: true,
filterable: true,
columnMenu: true,
pageable: {
pageSizes: true,
buttonCount: 5,
input: true,
refresh: true,// 是否允许刷新页面
numeric: false
},
columns: [{
field: "STATIONCODE",
title: "编号",
width: 200
},
{
field: "RECEIVETIME",
title: "时间"
},
{
field: "PM25",
title: "PM25"
},
{
field: "PM10",
title: "PM10"
},
{
field: "TEMPERATURE",
title: "温度"
},
{
field: "HUMIDITY",
title: "湿度"
}]
});
}
}