0

json ソースからのデータを使用して、jqxGrid にドロップダウンリストを表示しようとしています。

私が今持っているコードは(簡略化された)です:

var dropDownListSource =
{
    datatype: "json",
    datafields: [
        { name: 'name' },
        { term_id: 'term_id' }
    ],
    id: 'term_id',
    url: Ajax.ajaxurl,
    mtype: 'POST',
    data: {
       action: 'get_taxonomy_terms'
    }
    };

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



// initialize jqxGrid
    $("#jqxgrid").jqxGrid(
columns:
    [
    { text: 'Category', columntype: 'dropdownlist', datafield: 'category', width: 177,
        initeditor: function (row, cellvalue, editor) {
           editor.jqxDropDownList({ displayMember: 'name', source: dropdownListAdapter });
        }
    }
    ]           
 });

JSON は次のとおりです。

[{"term_id":"17","name":"category name","slug":"nova-kategorie-2","term_group":"0","term_taxonomy_id":"17","taxonomy":"budget-category","description":"","parent":"0","count":"0"}]

このコードはドロップダウンを表示しますが、名前を表示し、term_id を保存する必要があります。

どうやってやるの?

4

1 に答える 1

1

これがあなたが探しているものの例です!

他にもたくさんのオプションがあります!しかし、これは、ドロップダウンリストのソースを知っているか、独自のソースを構築できる場合の組み込みのようなものです

http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxgrid/gridkeyvaluescolumnwitharray.htm?arctic

于 2014-12-16T07:17:13.660 に答える