1

DropDown 列で gjqxGrid を読み込もうとしています。jsfiddle でサンプル json を試しました。ここでは、正常に動作しました。しかし、プロジェクトファイルで同じコードを使用しようとすると、ドロップダウン列が空になり、データ形式を確認しましたが、問題ありません。以下はプロジェクトファイルのコードです

        var source_app =
            {
                datatype: "json",
                datafields:[
                    { name: 'id' },
                    { name: 'name' },
                    { name: 'count' },
                    { name: 'drop'},
                    { name: 'drops'}                        
                ],
                url: "settings/scenario_count2.php",
                cache:false,
                                updaterow: function (rowid, rowdata, commit) {
                    var data = "update=true&" + $.param(rowdata);
                    $.ajax({
                        dataType: 'json',
                        url: 'settings/scenario_count2.php',
                        cache: false,
                        data: data,
                        success: function (data, status, xhr) {
                            // update command is executed.
                            commit(true);
                        },
                        /*
                        error: function(jqXHR, textStatus, errorThrown)
                        {
                            commit(false);
                        }*/
                    });
                }
            };
            var dataAdapter_app = new $.jqx.dataAdapter(source_app);
            dataAdapter_app.dataBind();

// 以下は私の Jqx グリッド初期化コードです // アプローチ 1

$("#scenario_grid2").jqxGrid(
            {
                width: 520,
                height: 253,
                source: dataAdapter_app,
                editable: true,
                theme: theme,

                selectionmode: 'multiplecellsadvanced',
                columns: [
                    { text: 'Id', hidden: true, editable:false, columntype: 'textbox', datafield: 'id'},
                    { text: 'Name', columntype: 'textbox', datafield: 'name', width: 140 },
                    /*{ text: 'Drop', columntype: 'NumberInput', datafield: 'drop', width: 60 },  */

                       { text: 'Drop', 
                       datafield: 'drop', width: 160, columntype: "dropdownlist", 
                       initeditor: function (row, cellvalue, editor) {
                       editor.jqxDropDownList ({source: dataAdapter_app.records[row].drops });

                       }},

ドロップ列には、ドロップダウンで pe する必要がある値の配列があります。また、データフィールド 'drop' を 'drops' に置き換えると、列にカンマ区切りの値が表示されます。つまり、配列データは存在しますが、ドロップダウンは作成されません。.

グリッドの初期化の前にドロップダウン アダプターを作成した場合 // アプローチ 2

  var dropdownListStateAdapter3 = new $.jqx.dataAdapter(dropDownListStateSource3, { autoBind: true, async: false });

これを以下のように使用します。

{ text: 'State', columntype: 'dropdownlist', datafield: 'revision_state', width: 55,
                        initeditor: function (row, cellvalue, editor) {
                                editor.jqxDropDownList({ displayMember: 'name', source: dropdownListStateAdapter3 });

次に、ドロップダウンを取得しますが、各行には異なるドロップダウン値のセットがあるため、動的ドロップダウンが必要です。アプローチ 1 を使用してドロップダウンにデータを入力する方法を教えてください。

ありがとう。

4

2 に答える 2

0

aynch:false と autobind:true を dataAdapter 関数に追加する必要があります。

var dataAdapter_app = new $.jqx.dataAdapter(source_app,{
            loadComplete: function (record) {
              console.log(record);
                 datarecords = JSON.parse(JSON.stringify(record));
                 },
                 async:false,
                 autoBind:true
            });
于 2015-03-20T10:42:33.590 に答える