这是昨天没有问题的工作。但是,自从今天早上离开并返回我的工作站后,我无法识别出我的代码有任何明显的变化。
我有一个 ASP.NET MVC 5 控制器方法,它返回一个 JsonAction 对象,并且不接受任何参数 (HttpGet)。我已经测试了它的返回,它返回了正确的 JSON——与我昨天没有这个问题时的结构相同。这似乎排除了服务器端的任何可能性。
对 dataBind 的调用使用如下所示的 URL:
/Home/GetAllUsersJSON?pk=userid&_=1413996086894
原因似乎是,在 Chrome 中检查,igGrid 的客户端 API 似乎在 dataBind() 期间将查询字符串附加(或尝试附加)到 dataSourceURL 的末尾。我什至无法识别任何相关数据库表中的第二个参数(也是无名的,似乎只是一个下划线字符)的值(换句话说,我不知道该值来自何处)--但是,它在每次调试尝试中都保持不变。
我只使用客户端 (JS) 来渲染和操作 igGrid。这是该代码:
$(document).ready(function () {
$('#usersgrid').igGrid({
autoGenerateColumns: false,
columns: [
{ headerText: 'userid', key: 'userid', dataType: 'number' },
{ headerText: 'username', key: 'username', dataType: 'string' },
{ headerText: 'login', key: 'loginid', dataType: 'string' },
{ headerText: 'role', key: 'role', dataType: 'string' },
{ headerText: 'distributor', key: 'distributorid', dataType: 'number' },
{ headerText: 'inactive', key: 'inactive', dataType: 'boolean' },
{ headerText: 'lastupdated', key: 'lastupdated', dataType: 'date', format: 'dateTime' }
],
dataSourceUrl: '/Home/GetAllUsersJSON',
primaryKey: 'userid',
features: [{
name: 'Updating',
enableAddRow: true,
enableDeleteRow: true,
columnSettings: [{
columnKey: 'userid',
editorOptions: { readonly: true, disabled: true }
}, {
columnKey: 'username',
editorType: 'string',
validation: true,
editorOptions: { required: true }
}, {
columnKey: 'loginid',
editorOptions: { readonly: true, disabled: true }
}, {
columnKey: 'role',
editorType: 'string',
validation: true,
editorOptions: { required: true }
}, {
columnKey: 'distributorid',
editorType: 'numeric',
validation: true,
editorOptions: { button: 'spin', minValue: 0, maxValue: 2000000, required: true }
}, {
columnKey: 'inactive',
editorType: 'combo',
editorOptions: {
mode: 'dropdown',
required: true,
dataSource: trueFalseValues,
textKey: 'text',
valueKey: 'value'
}
}, {
columnKey: 'lastupdated',
editorOptions: { readonly: true, disabled: true }
}]
} ]
}).igGrid('dataBind');
});