我是 devextreme dxDataGrid的新手我正在使用json我的 var objdata 以json字符串格式存储数据来获取值表单数据库,我正在传递 var objdata < / strong>作为dxDataGrid中的数据源,但是我在dxDataGrid 中收到错误的请求错误是我的 var objdata 中json字符串的图像任何帮助都将不胜感激
$(document).ready(function() {
fetchrecord();
});
function fetchrecord() { // calling fetch function
$.ajax({
type: "POST",
url: "Default.aspx/fetchemp",
data: '{}',
contentType: "application/json;charset=utf-8",
dataType: "json",
success: OnSuccess,
error: OnErrorCall
});
function OnSuccess(response) {
var objdata = (response.d); // storing data in json string format
$("#gridContainer").dxDataGrid({
allowColumnReordering: true,
allowColumnResizing: true,
columnChooser: {
enabled: true
},
columnFixing: {
enabled: true
},
filterRow: {
visible: true,
applyFilter: "auto"
},
searchPanel: {
visible: true,
width: 240,
placeholder: "Search..."
},
dataSource: objdata,
columns: ["ID", "Name", "Gender", "Pincode", "City"]
});
}
function OnErrorCall(response) {
alert("error occur");
}
}
&#13;
<div class="demo-container">
<div id="gridContainer"></div>
</div>
&#13;
答案 0 :(得分:1)
您身边的名字附带的数据并不相同,因为您输入了错误。
你必须这样做。
columns:["Id", "name", "gender", "pincode", "City"]
或
columns: [
{ dataField:'Id', caption: 'ID'},
{ dataField:'name', caption: 'Name'},
{ dataField:'gender',caption: 'Gender'},
{ dataField:'pincode',caption: 'Pincode'},
{ dataField:'City'}],