2 つの列を含む Jqxgrid のテーブルにデータを入力しようとしています。1 つはクライアントを含み、もう 1 つはグループ名を含むドロップボックスを含みます。
この部分は、ドロップダウン ボックスで使用されるデータを正常にフェッチします。Chrome はそれをコンソールに正常に記録します。
var groupsource =
{
datatype: "json",
datafields: [
{ name: 'groupname', type: 'string'},
{ name: 'groupid', type: 'integer'}
],
id: 'GroupID',
url: 'testje.php',
cache: false,
};
この部分もうまくいくようです:
var employeesAdapter = new $.jqx.dataAdapter(groupsource, {
autoBind: true,
beforeLoadComplete: function (records) {
var data = new Array();
// update the loaded records. Dynamically add EmployeeName and EmployeeID fields.
for (var i = 0; i < records.length; i++) {
var employee = records[i];
employee.GroupName = employee.groupname;
employee.GroupID = employee.groupid;
data.push(employee);
}
return data;
}
});
ただし、この部分はデータソースを正しくロードしていないようです。どのドロップダウンにもデータが含まれていません。コンソールにログインすると、そこにグループ名がないようです:
var source =
{
datatype: "json",
datafields: [
{ name: 'GroupName', value: 'GroupID', values: { source: employeesAdapter.records, value: 'GroupID', name: 'GroupName' } },
{ name: 'client'}
],
url: 'singlesgrid_data.php',
cache: false,
updaterow: function (rowid, rowdata){
// synchronize with the server - send update command
$.ajax({
dataType: 'json',
url: 'singlesgrid_data.php',
data: {'update' : 'true', 'client' : rowdata.client, 'groupid' : rowdata.groupid},
success: function (data, status, xhr){
// update command is executed.
}
});
}
};
明らかに、この出力も機能しません。
var dataAdapter = new $.jqx.dataAdapter(source);
$("#jqxgrid").jqxGrid(
{
source: dataAdapter,
editable: true,
sortable: true,
pageable: true,
columns: [
{ text: 'Groep', datafield: 'GroupID', displayfield: 'GroupName', columntype: 'dropdownlist', width: 150},
{ text: 'client', datafield: 'client', width: 250}
]
});
ソース変数にデータフィールドを入力する際に何が問題なのか誰か教えてもらえますか?