jQWidgets Forums

jQuery UI Widgets Forums Grid jqxgrid key / value

This topic contains 1 reply, has 2 voices, and was last updated by  Peter Stoev 12 years, 4 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • jqxgrid key / value #15372

    markcarpe
    Member

    I am having trouble with implementing key/value in the jqxgrid for displaying “enums” for a given field. I can change the field source OK, and enum ids match with field id but if I have fewer rows than enums, the dropdown list will only display a subset of the enums in the foreign source. (For instance if there are 2 rows only 2 options are listed in dropdown).

    I would like all three options available even if there is a single row…

    Code is below – can you tell me concept I am missing?

    <script>
    $(document).ready(function () {

    var theme = “classic”;

    /*—————————————————————————————————————————————————–*/

    var dataA = [{“postype”:{“id”: “1”, “label”: “Sales” }}, {“postype”:{“id”: “2”, “label”: “Tech” }},{“postype”:{“id”: “3”, “label”: “Other” }}];

    var sourceA =

    {

    localdata: dataA,

    datatype: ‘json’,

    record: ‘postype’,

    id: ‘id’,

    datafields: [

    { name: ‘id’, type: ‘number’, map:’postype>id’},

    { name: ‘label’, type: ‘string’,map:’postype>label’}

    ]

    };

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

    /*—————————————————————————————————————————————————–*/

    var dataB= [{“pos”:{“id”: “1”}}, {“pos”:{“id”: “2”}}, {“pos”:{“id”: “3”}}, {“pos”:{“id”: “2”}}];

    var sourceB =

    {

    localdata: dataB,

    datatype: “json”,

    datafields: [

    { name: ‘id’, map: ‘pos>id’, values: { source: dataAdapterA.records, name: ‘label’}}

    ],

    };

    var dataAdapterB = new $.jqx.dataAdapter(sourceB);

    /*—————————————————————————————————————————————————–*/ $(“#jqxgrid”).jqxGrid(

    {

    source: dataAdapterB,

    theme: theme,

    columnsresize: true,

    editable: true,

    selectionmode: ‘singlerow’,

    editmode: ‘dblclick’,

    columns: [

    {text: ‘id2label’, datafield: ‘id’, columntype: ‘dropdownlist’, width: 150}

    ]

    });

    });

    </script>
    jqxgrid key / value #15398

    Peter Stoev
    Keymaster

    Hi markcarpe,

    To display custom list of items within our Grid’s jqxDropDownList editor, please take a look at this sample:

    gridkeyvaluescolumnwitharray.htm.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.