0

我正在尝试在 Jqxgrid 中填充一个包含两列的表:一列包含客户端,一列包含包含组名的保管箱。

这部分成功获取要在下拉框中使用的数据。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}
    ]
});

有人可以告诉我在源变量中填充数据字段出了什么问题吗?

4

2 回答 2

0

解决方案是:

var groupsource =
        {
            datatype: "json",
            datafields: [
                { name: 'groupname', type: 'string'},
                { name: 'groupid', type: 'integer'}
            ],
            id: 'GroupID',
            url: 'testje.php',
            cache: false,
            async: false
         };

你也可以看看这个例子:jQWidgets Grid DropDownList Editor 希望这对你有帮助。

于 2014-03-17T19:48:12.017 回答
0

你有没有得到任何地方,我有一个类似的问题,但你有没有尝试过autoBind: true你的dataAdapter:

var dataAdapter = new $.jqx.dataAdapter(source, { autoBind: true });

这将字段中的值转换为我的实际名称,但它没有列出网格中不存在的字段可用的任何值。

于 2015-02-28T20:15:57.743 回答