jQWidgets Forums

jQuery UI Widgets Forums DataTable How is the ID supposed to work in a column with a DropDownList?

This topic contains 2 replies, has 2 voices, and was last updated by  cliftonm 10 years, 5 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author

  • cliftonm
    Participant

    I have this:

    text: 'Unit', columntype: 'template', dataField: 'UnitId', displayField: 'Abbr', width: '20%',
        createEditor: function (row, cellvalue, editor, cellText, width, height) {
        editor.jqxDropDownList({ source: daUnitList, displayMember: 'Abbr', valueMember: 'Id', width: width, height: height });
    },
    initEditor: function (row, cellvalue, editor, celltext, width, height) {
        editor.jqxDropDownList({ width: width, height: height });
        editor.val(cellvalue);
    },
    getEditorValue: function (row, cellvalue, editor) {
        return editor.val();
    }
    

    The daUnitList maps to a data source where Id is the primary key.
    The data table maps to a data source that has a UnitId and an Abbr field.

    1: I wouldn’t expect that I should need the Abbr field in the data table’s data source — why doesn’t the column populate with the display member from the DropDownList based on its valueMember value?

    2: If I use the valueMember of “Id’ in the DropDownList, when I edit the row, the DropDownList says “Please Choose:”. Why? Why can’t it select the correct value given the dataField’s value for the cell?

    3: If I change the DropDownList’s valueMember to “Abbr”, then it displays the correct value when I select edit, but when I hit enter, the resulting update certainly doesn’t give me a new UnitId. Why not?

    In other words, how do you get a column in a DataTable to work correctly with ID values and still dispay the display the associated text value correctly?


    Peter Stoev
    Keymaster

    Hello cliftonm,

    The DataTable does not have DropDownlist editor. It has only Text Editors.
    How to create custom Editors is demonstrated here: http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxdatatable/javascript-datatable-custom-editors.htm?arctic. If you want to select specific values of your editors, you will have to write code about that within the initEditor callback function.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com


    cliftonm
    Participant

    That’s exactly the example I’ve been using. And in that example, you have:

    displayMember: 'productname', valueMember: 'productname',

    What I want is for the valueMember to be an ID and for it to set the dataField of the “text” field.

    I take it from your comment that this doesn’t happen automatically, that I would have to implement this manually through, say, the select event of the dropdown list?

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

You must be logged in to reply to this topic.